2020-06-26 02:42:10 +02:00
|
|
|
<script lang="typescript">
|
2020-11-01 05:26:58 +01:00
|
|
|
import { defaultGraphBounds, GraphRange, RevlogRange } from "./graph-helpers";
|
2020-06-26 02:42:10 +02:00
|
|
|
import AxisTicks from "./AxisTicks.svelte";
|
2020-07-17 05:46:06 +02:00
|
|
|
import { renderButtons } from "./buttons";
|
2020-11-01 05:26:58 +01:00
|
|
|
import type pb from "anki/ts/lib/backend_proto";
|
|
|
|
import type { I18n } from "anki/ts/lib/i18n";
|
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";
|
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
|
|
|
|
|
|
|
const title = i18n.tr(i18n.TR.STATISTICS_ANSWER_BUTTONS_TITLE);
|
2020-06-28 09:44:51 +02:00
|
|
|
const subtitle = i18n.tr(i18n.TR.STATISTICS_ANSWER_BUTTONS_SUBTITLE);
|
2020-06-26 02:42:10 +02:00
|
|
|
</script>
|
|
|
|
|
2020-07-16 20:44:21 +02:00
|
|
|
<div class="graph" id="graph-buttons">
|
2020-06-28 06:21:31 +02:00
|
|
|
<h1>{title}</h1>
|
2020-06-26 02:42:10 +02:00
|
|
|
|
2020-08-04 09:40:26 +02:00
|
|
|
<div class="subtitle">{subtitle}</div>
|
|
|
|
|
2020-07-17 05:46:06 +02:00
|
|
|
<div class="range-box-inner">
|
2020-07-17 06:00:23 +02:00
|
|
|
<GraphRangeRadios bind:graphRange {i18n} {revlogRange} followRevlog={true} />
|
2020-07-17 05:46:06 +02:00
|
|
|
</div>
|
|
|
|
|
2020-06-26 02:42:10 +02:00
|
|
|
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
|
|
|
|
<g class="bars" />
|
|
|
|
<g class="hoverzone" />
|
|
|
|
<AxisTicks {bounds} />
|
2020-07-06 06:01:49 +02:00
|
|
|
<NoDataOverlay {bounds} {i18n} />
|
2020-06-26 02:42:10 +02:00
|
|
|
</svg>
|
|
|
|
</div>
|