anki/ts/src/stats/ButtonsGraph.svelte

36 lines
1.1 KiB
Svelte
Raw Normal View History

<script lang="typescript">
import { defaultGraphBounds } from "./graphs";
import AxisTicks from "./AxisTicks.svelte";
import { gatherData, GraphData, renderButtons } from "./buttons";
import pb from "../backend/proto";
2020-06-28 06:21:31 +02:00
import { I18n } from "../i18n";
2020-07-06 06:01:49 +02:00
import NoDataOverlay from "./NoDataOverlay.svelte";
export let sourceData: pb.BackendProto.GraphsOut | null = null;
2020-06-28 06:21:31 +02:00
export let i18n: I18n;
const bounds = defaultGraphBounds();
let svg = null as HTMLElement | SVGElement | null;
$: if (sourceData) {
2020-06-28 12:52:38 +02:00
renderButtons(svg as SVGElement, bounds, gatherData(sourceData), i18n);
}
2020-06-28 06:21:31 +02:00
const title = i18n.tr(i18n.TR.STATISTICS_ANSWER_BUTTONS_TITLE);
const subtitle = i18n.tr(i18n.TR.STATISTICS_ANSWER_BUTTONS_SUBTITLE);
</script>
<div class="graph" id="graph-buttons">
2020-06-28 06:21:31 +02:00
<h1>{title}</h1>
<div class="subtitle">{subtitle}</div>
<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} />
</svg>
</div>