anki/ts/graphs/HistogramGraph.svelte

25 lines
809 B
Svelte
Raw Normal View History

2020-06-23 11:07:47 +02:00
<script lang="typescript">
import type { HistogramData } from "./histogram-graph";
import { histogramGraph } from "./histogram-graph";
2020-06-23 11:07:47 +02:00
import AxisTicks from "./AxisTicks.svelte";
import { defaultGraphBounds } from "./graph-helpers";
2020-07-06 06:01:49 +02:00
import NoDataOverlay from "./NoDataOverlay.svelte";
import type { I18n } from "anki/i18n";
2020-06-23 11:07:47 +02:00
export let data: HistogramData | null = null;
2020-07-06 06:01:49 +02:00
export let i18n: I18n;
2020-06-23 11:07:47 +02:00
let bounds = defaultGraphBounds();
let svg = null as HTMLElement | SVGElement | null;
2020-07-06 06:01:49 +02:00
$: histogramGraph(svg as SVGElement, bounds, data);
2020-06-23 11:07:47 +02:00
</script>
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
<g class="bars" />
<g class="hoverzone" />
<path class="area" />
<AxisTicks {bounds} />
2020-07-06 06:01:49 +02:00
<NoDataOverlay {bounds} {i18n} />
2020-06-23 11:07:47 +02:00
</svg>