anki/ts/graphs/HistogramGraph.svelte

29 lines
922 B
Svelte
Raw Normal View History

2020-06-23 11:07:47 +02:00
<script lang="typescript">
import type { I18n } from "anki/i18n";
2020-06-23 11:07:47 +02:00
import AxisTicks from "./AxisTicks.svelte";
2020-07-06 06:01:49 +02:00
import NoDataOverlay from "./NoDataOverlay.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte";
import HoverColumns from "./HoverColumns.svelte";
import type { HistogramData } from "./histogram-graph";
import { histogramGraph } from "./histogram-graph";
import { defaultGraphBounds } from "./graph-helpers";
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" />
<HoverColumns />
<CumulativeOverlay />
2020-06-23 11:07:47 +02:00
<AxisTicks {bounds} />
2020-07-06 06:01:49 +02:00
<NoDataOverlay {bounds} {i18n} />
2020-06-23 11:07:47 +02:00
</svg>