anki/ts/graphs/HistogramGraph.svelte

29 lines
969 B
Svelte
Raw Normal View History

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
2020-06-23 11:07:47 +02:00
import AxisTicks from "./AxisTicks.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte";
import { defaultGraphBounds } from "./graph-helpers";
import type { HistogramData } from "./histogram-graph";
import { histogramGraph } from "./histogram-graph";
import HoverColumns from "./HoverColumns.svelte";
import NoDataOverlay from "./NoDataOverlay.svelte";
2020-06-23 11:07:47 +02:00
export let data: HistogramData | null = null;
const bounds = defaultGraphBounds();
2020-06-23 11:07:47 +02:00
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} />
<NoDataOverlay {bounds} />
2020-06-23 11:07:47 +02:00
</svg>