2020-06-26 11:25:02 +02:00
|
|
|
<script lang="typescript">
|
2021-03-21 13:47:52 +01:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2020-11-05 02:01:30 +01:00
|
|
|
import type { I18n } from "anki/i18n";
|
2021-03-21 13:47:52 +01:00
|
|
|
import type pb from "anki/backend_proto";
|
|
|
|
|
|
|
|
import Graph from "./Graph.svelte";
|
|
|
|
import InputBox from "./InputBox.svelte";
|
|
|
|
import HistogramGraph from "./HistogramGraph.svelte";
|
|
|
|
import GraphRangeRadios from "./GraphRangeRadios.svelte";
|
|
|
|
import TableData from "./TableData.svelte";
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
import type { HistogramData } from "./histogram-graph";
|
|
|
|
import { GraphRange, RevlogRange } from "./graph-helpers";
|
2021-01-26 12:41:22 +01:00
|
|
|
import type { TableDatum, SearchEventMap } from "./graph-helpers";
|
2020-11-01 05:26:58 +01:00
|
|
|
import { gatherData, buildHistogram } from "./future-due";
|
|
|
|
import type { GraphData } from "./future-due";
|
2021-01-25 17:36:04 +01:00
|
|
|
import type { PreferenceStore } from "./preferences";
|
2020-06-26 11:25:02 +02:00
|
|
|
|
|
|
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-06-27 14:10:56 +02:00
|
|
|
export let i18n: I18n;
|
2021-01-25 17:36:04 +01:00
|
|
|
export let preferences: PreferenceStore;
|
2020-06-27 14:10:56 +02:00
|
|
|
|
2021-01-26 12:41:22 +01:00
|
|
|
const dispatch = createEventDispatcher<SearchEventMap>();
|
2021-01-25 16:33:18 +01:00
|
|
|
|
2020-06-26 11:25:02 +02:00
|
|
|
let graphData = null as GraphData | null;
|
|
|
|
let histogramData = null as HistogramData | null;
|
2020-08-04 07:15:57 +02:00
|
|
|
let tableData: TableDatum[] = [] as any;
|
2020-07-17 05:46:06 +02:00
|
|
|
let graphRange: GraphRange = GraphRange.Month;
|
2021-01-27 01:15:19 +01:00
|
|
|
let { browserLinksSupported, futureDueShowBacklog } = preferences;
|
2020-06-26 11:25:02 +02:00
|
|
|
|
|
|
|
$: if (sourceData) {
|
|
|
|
graphData = gatherData(sourceData);
|
|
|
|
}
|
|
|
|
|
|
|
|
$: if (graphData) {
|
2020-08-10 06:37:23 +02:00
|
|
|
({ histogramData, tableData } = buildHistogram(
|
2020-08-04 07:15:57 +02:00
|
|
|
graphData,
|
|
|
|
graphRange,
|
2021-01-27 01:15:19 +01:00
|
|
|
$futureDueShowBacklog,
|
2021-01-25 16:33:18 +01:00
|
|
|
i18n,
|
|
|
|
dispatch,
|
2021-01-25 17:36:04 +01:00
|
|
|
$browserLinksSupported
|
2020-08-10 06:37:23 +02:00
|
|
|
));
|
2020-06-26 11:25:02 +02:00
|
|
|
}
|
2020-06-27 14:10:56 +02:00
|
|
|
|
2021-03-26 10:13:20 +01:00
|
|
|
const title = i18n.statisticsFutureDueTitle();
|
|
|
|
const subtitle = i18n.statisticsFutureDueSubtitle();
|
|
|
|
const backlogLabel = i18n.statisticsBacklogCheckbox();
|
2020-06-26 11:25:02 +02:00
|
|
|
</script>
|
|
|
|
|
2021-03-21 13:47:52 +01:00
|
|
|
<Graph {title} {subtitle}>
|
|
|
|
<InputBox>
|
2020-08-10 06:37:23 +02:00
|
|
|
{#if graphData && graphData.haveBacklog}
|
|
|
|
<label>
|
2021-01-27 01:15:19 +01:00
|
|
|
<input type="checkbox" bind:checked={$futureDueShowBacklog} />
|
2020-08-10 06:37:23 +02:00
|
|
|
{backlogLabel}
|
|
|
|
</label>
|
|
|
|
{/if}
|
2020-06-26 11:25:02 +02:00
|
|
|
|
2020-07-17 05:46:06 +02:00
|
|
|
<GraphRangeRadios bind:graphRange {i18n} revlogRange={RevlogRange.All} />
|
2021-03-21 13:47:52 +01:00
|
|
|
</InputBox>
|
2020-06-26 11:25:02 +02:00
|
|
|
|
2021-01-25 17:36:04 +01:00
|
|
|
<HistogramGraph data={histogramData} {i18n} />
|
2020-06-26 11:25:02 +02:00
|
|
|
|
2020-08-04 07:15:57 +02:00
|
|
|
<TableData {i18n} {tableData} />
|
2021-03-21 13:47:52 +01:00
|
|
|
</Graph>
|