anki/ts/graphs/EaseGraph.svelte

44 lines
1.4 KiB
Svelte
Raw Normal View History

2020-06-23 12:43:19 +02:00
<script lang="typescript">
import type { HistogramData } from "./histogram-graph";
2020-07-22 06:11:22 +02:00
import { gatherData, prepareData } from "./ease";
import type pb from "anki/backend_proto";
2020-06-23 12:43:19 +02:00
import HistogramGraph from "./HistogramGraph.svelte";
import type { I18n } from "anki/i18n";
import type { TableDatum, SearchEventMap } from "./graph-helpers";
2020-08-21 04:58:02 +02:00
import TableData from "./TableData.svelte";
import { createEventDispatcher } from "svelte";
2021-01-25 17:36:04 +01:00
import type { PreferenceStore } from "./preferences";
2020-06-23 12:43:19 +02:00
export let sourceData: pb.BackendProto.GraphsOut | null = null;
2020-06-28 06:21:31 +02:00
export let i18n: I18n;
2021-01-25 17:36:04 +01:00
export let preferences: PreferenceStore;
2020-06-23 12:43:19 +02:00
const dispatch = createEventDispatcher<SearchEventMap>();
2020-06-23 12:43:19 +02:00
let histogramData = null as HistogramData | null;
2020-08-21 04:58:02 +02:00
let tableData: TableDatum[] = [];
2021-01-25 17:36:04 +01:00
let { browserLinksSupported } = preferences;
2020-06-23 12:43:19 +02:00
$: if (sourceData) {
2021-01-25 17:36:04 +01:00
[histogramData, tableData] = prepareData(
gatherData(sourceData),
i18n,
dispatch,
$browserLinksSupported
);
2020-06-23 12:43:19 +02:00
}
2020-06-28 06:21:31 +02:00
const title = i18n.tr(i18n.TR.STATISTICS_CARD_EASE_TITLE);
2020-06-28 12:52:38 +02:00
const subtitle = i18n.tr(i18n.TR.STATISTICS_CARD_EASE_SUBTITLE);
2020-06-23 12:43:19 +02:00
</script>
<div class="graph" id="graph-ease">
2020-07-06 06:01:49 +02:00
<h1>{title}</h1>
2020-06-23 12:43:19 +02:00
2020-07-06 06:01:49 +02:00
<div class="subtitle">{subtitle}</div>
2021-01-25 17:36:04 +01:00
<HistogramGraph data={histogramData} {i18n} />
2020-08-21 04:58:02 +02:00
<TableData {i18n} {tableData} />
2020-07-06 06:01:49 +02:00
</div>