2020-06-24 01:41:07 +02:00
|
|
|
<script lang="typescript">
|
|
|
|
import { HistogramData } from "./histogram-graph";
|
|
|
|
import { gatherData, prepareData, GraphData, AddedRange } from "./added";
|
|
|
|
import pb from "../backend/proto";
|
|
|
|
import HistogramGraph from "./HistogramGraph.svelte";
|
|
|
|
|
2020-06-26 02:42:10 +02:00
|
|
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-06-24 01:41:07 +02:00
|
|
|
|
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
|
|
|
let histogramData = null as HistogramData | null;
|
|
|
|
let range = AddedRange.Month;
|
|
|
|
|
|
|
|
let addedData: GraphData | null = null;
|
2020-06-26 02:42:10 +02:00
|
|
|
$: if (sourceData) {
|
2020-06-24 01:41:07 +02:00
|
|
|
console.log("gathering data");
|
2020-06-26 02:42:10 +02:00
|
|
|
addedData = gatherData(sourceData);
|
2020-06-24 01:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$: if (addedData) {
|
|
|
|
console.log("preparing data");
|
|
|
|
histogramData = prepareData(addedData, range);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if histogramData}
|
|
|
|
<div class="graph">
|
|
|
|
<h1>Added</h1>
|
|
|
|
|
2020-06-26 07:34:21 +02:00
|
|
|
<div class="range-box-inner">
|
2020-06-24 01:41:07 +02:00
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.Month} />
|
|
|
|
Month
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.Quarter} />
|
|
|
|
3 months
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.Year} />
|
|
|
|
Year
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.AllTime} />
|
|
|
|
All time
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<HistogramGraph data={histogramData} xText="Days" yText="Number of cards" />
|
|
|
|
</div>
|
|
|
|
{/if}
|