2020-06-22 07:00:45 +02:00
|
|
|
<script lang="typescript">
|
2020-06-23 07:38:54 +02:00
|
|
|
import AxisLabels from "./AxisLabels.svelte";
|
|
|
|
import AxisTicks from "./AxisTicks.svelte";
|
2020-06-23 05:43:23 +02:00
|
|
|
|
2020-06-23 07:38:54 +02:00
|
|
|
import { defaultGraphBounds } from "./graphs";
|
2020-06-23 05:43:23 +02:00
|
|
|
import { gatherIntervalData, intervalGraph, IntervalRange } from "./intervals";
|
2020-06-22 07:00:45 +02:00
|
|
|
import type { IntervalGraphData } from "./intervals";
|
|
|
|
import pb from "../backend/proto";
|
|
|
|
|
2020-06-22 11:11:50 +02:00
|
|
|
export let data: pb.BackendProto.GraphsOut | null = null;
|
2020-06-22 07:00:45 +02:00
|
|
|
|
2020-06-23 07:38:54 +02:00
|
|
|
const bounds = defaultGraphBounds();
|
|
|
|
|
2020-06-22 07:00:45 +02:00
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
|
|
|
let range = IntervalRange.Percentile95;
|
|
|
|
|
2020-06-22 11:11:50 +02:00
|
|
|
let intervalData: IntervalGraphData | null = null;
|
|
|
|
$: if (data) {
|
|
|
|
console.log("gathering data");
|
|
|
|
intervalData = gatherIntervalData(data);
|
|
|
|
}
|
|
|
|
|
2020-06-23 05:43:23 +02:00
|
|
|
$: if (intervalData) {
|
|
|
|
intervalGraph(svg as SVGElement, bounds, intervalData, range);
|
2020-06-22 07:00:45 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="graph intervals">
|
|
|
|
<h1>Review Intervals</h1>
|
|
|
|
|
|
|
|
<div class="range-box">
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={IntervalRange.Month} />
|
|
|
|
Month
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={IntervalRange.Percentile50} />
|
|
|
|
50th percentile
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={IntervalRange.Percentile95} />
|
|
|
|
95th percentile
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
bind:group={range}
|
|
|
|
value={IntervalRange.Percentile999} />
|
|
|
|
99.9th percentile
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={IntervalRange.All} />
|
|
|
|
All
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
2020-06-23 05:43:23 +02:00
|
|
|
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
|
|
|
|
<g class="bars" />
|
|
|
|
<g class="hoverzone" />
|
2020-06-22 07:00:45 +02:00
|
|
|
<path class="area" />
|
2020-06-23 07:38:54 +02:00
|
|
|
<AxisTicks {bounds} />
|
|
|
|
<AxisLabels {bounds} xText="Interval (days)" yText="Number of cards" />
|
2020-06-22 07:00:45 +02:00
|
|
|
</svg>
|
|
|
|
</div>
|