anki/ts/src/stats/AddedGraph.svelte

40 lines
1.2 KiB
Svelte
Raw Normal View History

2020-06-24 01:41:07 +02:00
<script lang="typescript">
import { RevlogRange, GraphRange } from "./graphs";
2020-06-27 14:10:56 +02:00
import { I18n } from "../i18n";
2020-06-24 01:41:07 +02:00
import { HistogramData } from "./histogram-graph";
import { gatherData, buildHistogram, GraphData } from "./added";
2020-06-24 01:41:07 +02:00
import pb from "../backend/proto";
import HistogramGraph from "./HistogramGraph.svelte";
import GraphRangeRadios from "./GraphRangeRadios.svelte";
2020-06-24 01:41:07 +02:00
export let sourceData: pb.BackendProto.GraphsOut | null = null;
2020-06-27 14:10:56 +02:00
export let i18n: I18n;
2020-06-24 01:41:07 +02:00
let histogramData = null as HistogramData | null;
let graphRange: GraphRange = GraphRange.Month;
2020-06-24 01:41:07 +02:00
let addedData: GraphData | null = null;
$: if (sourceData) {
addedData = gatherData(sourceData);
2020-06-24 01:41:07 +02:00
}
$: if (addedData) {
histogramData = buildHistogram(addedData, graphRange, i18n);
2020-06-24 01:41:07 +02:00
}
2020-06-27 14:10:56 +02:00
2020-06-28 06:21:31 +02:00
const title = i18n.tr(i18n.TR.STATISTICS_ADDED_TITLE);
const subtitle = i18n.tr(i18n.TR.STATISTICS_ADDED_SUBTITLE);
2020-06-24 01:41:07 +02:00
</script>
<div class="graph" id="graph-added">
2020-07-06 06:01:49 +02:00
<h1>{title}</h1>
2020-06-24 01:41:07 +02:00
2020-07-06 06:01:49 +02:00
<div class="range-box-inner">
<GraphRangeRadios bind:graphRange {i18n} revlogRange={RevlogRange.All} />
2020-07-06 06:01:49 +02:00
</div>
2020-06-24 01:41:07 +02:00
2020-07-06 06:01:49 +02:00
<div class="subtitle">{subtitle}</div>
2020-07-06 06:01:49 +02:00
<HistogramGraph data={histogramData} {i18n} />
</div>