2020-06-26 02:42:10 +02:00
|
|
|
<script lang="typescript">
|
2020-11-05 02:01:30 +01:00
|
|
|
import type pb from "anki/backend_proto";
|
|
|
|
import type { I18n } from "anki/i18n";
|
2021-03-21 13:47:52 +01:00
|
|
|
|
|
|
|
import Graph from "./Graph.svelte";
|
|
|
|
import InputBox from "./InputBox.svelte";
|
|
|
|
import AxisTicks from "./AxisTicks.svelte";
|
2020-07-06 06:01:49 +02:00
|
|
|
import NoDataOverlay from "./NoDataOverlay.svelte";
|
2020-07-17 05:46:06 +02:00
|
|
|
import GraphRangeRadios from "./GraphRangeRadios.svelte";
|
2021-03-21 10:58:39 +01:00
|
|
|
import HoverColumns from "./HoverColumns.svelte";
|
2021-03-21 13:47:52 +01:00
|
|
|
import { renderButtons } from "./buttons";
|
|
|
|
import { defaultGraphBounds, GraphRange, RevlogRange } from "./graph-helpers";
|
2020-06-26 02:42:10 +02:00
|
|
|
|
|
|
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-06-28 06:21:31 +02:00
|
|
|
export let i18n: I18n;
|
2020-07-17 05:46:06 +02:00
|
|
|
export let revlogRange: RevlogRange;
|
|
|
|
|
|
|
|
let graphRange: GraphRange = GraphRange.Year;
|
2020-06-26 02:42:10 +02:00
|
|
|
|
|
|
|
const bounds = defaultGraphBounds();
|
|
|
|
|
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
|
|
|
|
|
|
|
$: if (sourceData) {
|
2020-07-17 05:46:06 +02:00
|
|
|
renderButtons(svg as SVGElement, bounds, sourceData, i18n, graphRange);
|
2020-06-26 02:42:10 +02:00
|
|
|
}
|
2020-06-28 06:21:31 +02:00
|
|
|
|
2021-03-26 10:13:20 +01:00
|
|
|
const title = i18n.statisticsAnswerButtonsTitle();
|
|
|
|
const subtitle = i18n.statisticsAnswerButtonsSubtitle();
|
2020-06-26 02:42:10 +02:00
|
|
|
</script>
|
|
|
|
|
2021-03-21 13:47:52 +01:00
|
|
|
<Graph {title} {subtitle}>
|
|
|
|
<InputBox>
|
2020-07-17 06:00:23 +02:00
|
|
|
<GraphRangeRadios bind:graphRange {i18n} {revlogRange} followRevlog={true} />
|
2021-03-21 13:47:52 +01:00
|
|
|
</InputBox>
|
2020-07-17 05:46:06 +02:00
|
|
|
|
2020-06-26 02:42:10 +02:00
|
|
|
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
|
|
|
|
<g class="bars" />
|
2021-03-21 10:58:39 +01:00
|
|
|
<HoverColumns />
|
2020-06-26 02:42:10 +02:00
|
|
|
<AxisTicks {bounds} />
|
2020-07-06 06:01:49 +02:00
|
|
|
<NoDataOverlay {bounds} {i18n} />
|
2020-06-26 02:42:10 +02:00
|
|
|
</svg>
|
2021-03-21 13:47:52 +01:00
|
|
|
</Graph>
|