2020-06-27 04:35:13 +02:00
|
|
|
<script lang="typescript">
|
|
|
|
import AxisTicks from "./AxisTicks.svelte";
|
2020-07-17 05:46:06 +02:00
|
|
|
import { defaultGraphBounds, RevlogRange, GraphRange } from "./graphs";
|
|
|
|
import { GraphData, gatherData, renderReviews } from "./reviews";
|
2020-06-27 04:35:13 +02:00
|
|
|
import pb from "../backend/proto";
|
2020-06-27 14:10:56 +02:00
|
|
|
import { I18n } from "../i18n";
|
2020-07-06 06:01:49 +02:00
|
|
|
import NoDataOverlay from "./NoDataOverlay.svelte";
|
2020-07-17 05:46:06 +02:00
|
|
|
import GraphRangeRadios from "./GraphRangeRadios.svelte";
|
2020-06-27 04:35:13 +02:00
|
|
|
|
|
|
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
2020-07-06 10:29:35 +02:00
|
|
|
export let revlogRange: RevlogRange;
|
2020-06-27 14:10:56 +02:00
|
|
|
export let i18n: I18n;
|
2020-06-27 04:35:13 +02:00
|
|
|
|
|
|
|
let graphData: GraphData | null = null;
|
|
|
|
|
|
|
|
let bounds = defaultGraphBounds();
|
|
|
|
let svg = null as HTMLElement | SVGElement | null;
|
2020-07-17 05:46:06 +02:00
|
|
|
let graphRange: GraphRange = GraphRange.Month;
|
2020-06-27 04:35:13 +02:00
|
|
|
let showTime = false;
|
2020-06-27 07:35:34 +02:00
|
|
|
|
2020-06-27 04:35:13 +02:00
|
|
|
$: if (sourceData) {
|
|
|
|
graphData = gatherData(sourceData);
|
|
|
|
}
|
|
|
|
|
2020-08-04 06:28:46 +02:00
|
|
|
let tableStrings: [string, string][] = [];
|
2020-06-27 04:35:13 +02:00
|
|
|
$: if (graphData) {
|
2020-08-04 06:28:46 +02:00
|
|
|
tableStrings = renderReviews(
|
|
|
|
svg as SVGElement,
|
|
|
|
bounds,
|
|
|
|
graphData,
|
|
|
|
graphRange,
|
|
|
|
showTime,
|
|
|
|
i18n
|
|
|
|
);
|
2020-06-27 04:35:13 +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_REVIEWS_TITLE);
|
2020-06-28 11:34:19 +02:00
|
|
|
const time = i18n.tr(i18n.TR.STATISTICS_REVIEWS_TIME_CHECKBOX);
|
2020-06-28 07:23:36 +02:00
|
|
|
|
2020-07-22 06:11:22 +02:00
|
|
|
let subtitle = "";
|
2020-06-28 07:23:36 +02:00
|
|
|
$: if (showTime) {
|
2020-06-28 09:44:51 +02:00
|
|
|
subtitle = i18n.tr(i18n.TR.STATISTICS_REVIEWS_TIME_SUBTITLE);
|
2020-06-28 07:23:36 +02:00
|
|
|
} else {
|
2020-06-28 09:44:51 +02:00
|
|
|
subtitle = i18n.tr(i18n.TR.STATISTICS_REVIEWS_COUNT_SUBTITLE);
|
2020-06-28 07:23:36 +02:00
|
|
|
}
|
2020-06-27 04:35:13 +02:00
|
|
|
</script>
|
|
|
|
|
2020-07-16 20:44:21 +02:00
|
|
|
<div class="graph" id="graph-reviews">
|
2020-06-28 06:21:31 +02:00
|
|
|
<h1>{title}</h1>
|
2020-06-27 04:35:13 +02:00
|
|
|
|
|
|
|
<div class="range-box-inner">
|
|
|
|
<label>
|
|
|
|
<input type="checkbox" bind:checked={showTime} />
|
2020-06-28 11:34:19 +02:00
|
|
|
{time}
|
2020-06-27 04:35:13 +02:00
|
|
|
</label>
|
|
|
|
|
2020-07-17 06:00:23 +02:00
|
|
|
<GraphRangeRadios bind:graphRange {i18n} {revlogRange} followRevlog={true} />
|
2020-06-27 04:35:13 +02:00
|
|
|
</div>
|
|
|
|
|
2020-06-28 09:44:51 +02:00
|
|
|
<div class="subtitle">{subtitle}</div>
|
|
|
|
|
2020-06-27 04:35:13 +02:00
|
|
|
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
|
|
|
|
{#each [4, 3, 2, 1, 0] as i}
|
|
|
|
<g class="bars{i}" />
|
|
|
|
{/each}
|
|
|
|
<path class="area" />
|
|
|
|
<g class="hoverzone" />
|
|
|
|
<AxisTicks {bounds} />
|
2020-07-06 06:01:49 +02:00
|
|
|
<NoDataOverlay {bounds} {i18n} />
|
2020-06-27 04:35:13 +02:00
|
|
|
</svg>
|
|
|
|
|
2020-08-04 06:28:46 +02:00
|
|
|
<div class="centered">
|
|
|
|
<table dir={i18n.direction()}>
|
|
|
|
{#each tableStrings as [label, value]}
|
|
|
|
<tr>
|
|
|
|
<td class="align-end">{label}:</td>
|
|
|
|
<td class="align-start">{value}</td>
|
|
|
|
</tr>
|
|
|
|
{/each}
|
|
|
|
</table>
|
|
|
|
</div>
|
2020-06-27 04:35:13 +02:00
|
|
|
</div>
|