2020-06-24 01:41:07 +02:00
|
|
|
<script lang="typescript">
|
2020-06-29 07:30:56 +02:00
|
|
|
import { RevlogRange } from "./graphs";
|
2020-06-27 14:10:56 +02:00
|
|
|
import { timeSpan, MONTH, YEAR } from "../time";
|
|
|
|
import { I18n } from "../i18n";
|
2020-06-24 01:41:07 +02:00
|
|
|
import { HistogramData } from "./histogram-graph";
|
2020-06-26 11:25:02 +02:00
|
|
|
import { gatherData, buildHistogram, GraphData, AddedRange } from "./added";
|
2020-06-24 01:41:07 +02:00
|
|
|
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-27 14:10:56 +02:00
|
|
|
export let i18n: I18n;
|
2020-06-24 01:41:07 +02:00
|
|
|
|
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
|
|
|
let histogramData = null as HistogramData | null;
|
2020-07-06 10:29:35 +02:00
|
|
|
let range: AddedRange = AddedRange.Month;
|
2020-06-24 01:41:07 +02:00
|
|
|
|
|
|
|
let addedData: GraphData | null = null;
|
2020-06-26 02:42:10 +02:00
|
|
|
$: if (sourceData) {
|
|
|
|
addedData = gatherData(sourceData);
|
2020-06-24 01:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$: if (addedData) {
|
2020-06-28 12:52:38 +02:00
|
|
|
histogramData = buildHistogram(addedData, range, 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);
|
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_ADDED_SUBTITLE);
|
2020-06-24 01:41:07 +02:00
|
|
|
</script>
|
|
|
|
|
2020-07-16 20:44:21 +02:00
|
|
|
<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">
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.Month} />
|
|
|
|
{month}
|
|
|
|
</label>
|
|
|
|
<label>
|
2020-07-06 10:29:35 +02:00
|
|
|
<input type="radio" bind:group={range} value={AddedRange.ThreeMonths} />
|
2020-07-06 06:01:49 +02:00
|
|
|
{month3}
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.Year} />
|
|
|
|
{year}
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={range} value={AddedRange.AllTime} />
|
|
|
|
{all}
|
|
|
|
</label>
|
|
|
|
</div>
|
2020-06-24 01:41:07 +02:00
|
|
|
|
2020-07-06 06:01:49 +02:00
|
|
|
<div class="subtitle">{subtitle}</div>
|
2020-06-28 09:44:51 +02:00
|
|
|
|
2020-07-06 06:01:49 +02:00
|
|
|
<HistogramGraph data={histogramData} {i18n} />
|
|
|
|
</div>
|