2020-06-26 11:25:02 +02:00
|
|
|
<script lang="typescript">
|
2020-06-27 14:10:56 +02:00
|
|
|
import { timeSpan, MONTH, YEAR } from "../time";
|
|
|
|
import { I18n } from "../i18n";
|
2020-06-26 11:25:02 +02:00
|
|
|
import { HistogramData } from "./histogram-graph";
|
|
|
|
import { defaultGraphBounds } from "./graphs";
|
|
|
|
import {
|
|
|
|
gatherData,
|
|
|
|
renderFutureDue,
|
|
|
|
GraphData,
|
|
|
|
FutureDueRange,
|
|
|
|
buildHistogram,
|
|
|
|
} from "./future-due";
|
|
|
|
import pb from "../backend/proto";
|
|
|
|
import HistogramGraph from "./HistogramGraph.svelte";
|
|
|
|
|
|
|
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-06-27 14:10:56 +02:00
|
|
|
export let i18n: I18n;
|
|
|
|
|
2020-06-26 11:25:02 +02:00
|
|
|
let graphData = null as GraphData | null;
|
|
|
|
let histogramData = null as HistogramData | null;
|
|
|
|
|
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
|
|
|
let range = FutureDueRange.Month;
|
|
|
|
|
|
|
|
$: if (sourceData) {
|
|
|
|
graphData = gatherData(sourceData);
|
|
|
|
}
|
|
|
|
|
|
|
|
$: if (graphData) {
|
|
|
|
histogramData = buildHistogram(graphData, range);
|
|
|
|
}
|
2020-06-27 14:10:56 +02:00
|
|
|
|
2020-06-28 06:21:31 +02:00
|
|
|
const title = i18n.tr(i18n.TR.STATISTICS_FUTURE_DUE_TITLE);
|
2020-06-27 14:10:56 +02:00
|
|
|
const month = timeSpan(i18n, 1 * MONTH);
|
|
|
|
const month3 = timeSpan(i18n, 3 * MONTH);
|
|
|
|
const year = timeSpan(i18n, 1 * YEAR);
|
2020-06-28 05:46:17 +02:00
|
|
|
const all = i18n.tr(i18n.TR.STATISTICS_RANGE_ALL_TIME);
|
2020-06-28 09:44:51 +02:00
|
|
|
const subtitle = i18n.tr(i18n.TR.STATISTICS_FUTURE_DUE_SUBTITLE);
|
2020-06-26 11:25:02 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if histogramData}
|
|
|
|
|
|
|
|
<div class="graph">
|
2020-06-28 06:21:31 +02:00
|
|
|
<h1>{title}</h1>
|
2020-06-26 11:25:02 +02:00
|
|
|
|
|
|
|
<div class="range-box-inner">
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={FutureDueRange.Month} />
|
2020-06-27 14:10:56 +02:00
|
|
|
{month}
|
2020-06-26 11:25:02 +02:00
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={FutureDueRange.Quarter} />
|
2020-06-27 14:10:56 +02:00
|
|
|
{month3}
|
2020-06-26 11:25:02 +02:00
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={FutureDueRange.Year} />
|
2020-06-27 14:10:56 +02:00
|
|
|
{year}
|
2020-06-26 11:25:02 +02:00
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={FutureDueRange.AllTime} />
|
2020-06-28 05:46:17 +02:00
|
|
|
{all}
|
2020-06-26 11:25:02 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
|
2020-06-28 09:44:51 +02:00
|
|
|
<div class="subtitle">{subtitle}</div>
|
|
|
|
|
|
|
|
<HistogramGraph data={histogramData} />
|
2020-06-26 11:25:02 +02:00
|
|
|
|
|
|
|
</div>
|
|
|
|
{/if}
|