2020-06-26 02:42:10 +02:00
|
|
|
<script lang="typescript">
|
2020-07-04 05:38:46 +02:00
|
|
|
import { defaultGraphBounds } from "./graphs";
|
|
|
|
import { gatherData, GraphData, renderCards } from "./card-counts";
|
2020-06-26 02:42:10 +02:00
|
|
|
import pb from "../backend/proto";
|
2020-06-27 13:10:17 +02:00
|
|
|
import { I18n } from "../i18n";
|
2020-06-26 02:42:10 +02:00
|
|
|
|
|
|
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-06-27 13:10:17 +02:00
|
|
|
export let i18n: I18n;
|
2020-06-26 02:42:10 +02:00
|
|
|
|
2020-07-04 05:38:46 +02:00
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
|
|
|
|
|
|
|
let bounds = defaultGraphBounds();
|
|
|
|
bounds.height = 20;
|
|
|
|
bounds.marginLeft = 20;
|
|
|
|
bounds.marginRight = 20;
|
|
|
|
bounds.marginTop = 0;
|
|
|
|
|
|
|
|
let graphData: GraphData | null = null;
|
2020-06-26 02:42:10 +02:00
|
|
|
$: if (sourceData) {
|
2020-07-04 05:38:46 +02:00
|
|
|
graphData = gatherData(sourceData, i18n);
|
2020-06-26 02:42:10 +02:00
|
|
|
}
|
|
|
|
|
2020-07-04 05:38:46 +02:00
|
|
|
$: if (graphData) {
|
|
|
|
renderCards(svg as any, bounds, graphData);
|
2020-06-27 13:10:17 +02:00
|
|
|
}
|
|
|
|
|
2020-07-04 05:38:46 +02:00
|
|
|
const total = i18n.tr(i18n.TR.STATISTICS_COUNTS_TOTAL_CARDS);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if graphData}
|
2020-06-27 13:10:17 +02:00
|
|
|
<div class="graph">
|
2020-07-04 05:38:46 +02:00
|
|
|
<h1>{graphData.title}</h1>
|
|
|
|
|
|
|
|
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
|
|
|
|
<g class="days" />
|
|
|
|
</svg>
|
|
|
|
|
|
|
|
<div class="centered">{total}: {graphData.totalCards}</div>
|
|
|
|
|
2020-06-27 13:10:17 +02:00
|
|
|
</div>
|
|
|
|
{/if}
|