2021-04-13 11:02:41 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
2020-06-27 04:35:13 +02:00
|
|
|
<script lang="typescript">
|
2021-04-22 19:55:26 +02:00
|
|
|
import type pb from "lib/backend_proto";
|
2021-03-21 13:47:52 +01:00
|
|
|
|
|
|
|
import Graph from "./Graph.svelte";
|
|
|
|
import InputBox from "./InputBox.svelte";
|
2020-07-06 06:01:49 +02:00
|
|
|
import NoDataOverlay from "./NoDataOverlay.svelte";
|
2021-03-21 10:50:35 +01:00
|
|
|
import CumulativeOverlay from "./CumulativeOverlay.svelte";
|
2020-07-17 05:46:06 +02:00
|
|
|
import GraphRangeRadios from "./GraphRangeRadios.svelte";
|
2020-08-04 06:37:21 +02:00
|
|
|
import TableData from "./TableData.svelte";
|
2021-03-21 13:47:52 +01:00
|
|
|
import AxisTicks from "./AxisTicks.svelte";
|
2021-03-21 10:58:39 +01:00
|
|
|
import HoverColumns from "./HoverColumns.svelte";
|
2020-06-27 04:35:13 +02:00
|
|
|
|
2021-03-21 13:47:52 +01:00
|
|
|
import { defaultGraphBounds, RevlogRange, GraphRange } from "./graph-helpers";
|
|
|
|
import type { TableDatum } from "./graph-helpers";
|
|
|
|
import { gatherData, renderReviews } from "./reviews";
|
|
|
|
import type { GraphData } from "./reviews";
|
|
|
|
|
2021-06-20 07:49:20 +02:00
|
|
|
export let sourceData: pb.BackendProto.GraphsResponse | null = null;
|
2020-07-06 10:29:35 +02:00
|
|
|
export let revlogRange: RevlogRange;
|
2021-04-22 19:55:26 +02:00
|
|
|
import * as tr from "lib/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:37:21 +02:00
|
|
|
let tableData: TableDatum[] = [] as any;
|
2020-06-27 04:35:13 +02:00
|
|
|
$: if (graphData) {
|
2020-08-04 06:37:21 +02:00
|
|
|
tableData = renderReviews(
|
2020-08-04 06:28:46 +02:00
|
|
|
svg as SVGElement,
|
|
|
|
bounds,
|
|
|
|
graphData,
|
|
|
|
graphRange,
|
2021-03-26 11:23:43 +01:00
|
|
|
showTime
|
2020-08-04 06:28:46 +02:00
|
|
|
);
|
2020-06-27 04:35:13 +02:00
|
|
|
}
|
2020-06-27 14:10:56 +02:00
|
|
|
|
2021-03-26 11:23:43 +01:00
|
|
|
const title = tr.statisticsReviewsTitle();
|
|
|
|
const time = tr.statisticsReviewsTimeCheckbox();
|
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) {
|
2021-03-26 11:23:43 +01:00
|
|
|
subtitle = tr.statisticsReviewsTimeSubtitle();
|
2020-06-28 07:23:36 +02:00
|
|
|
} else {
|
2021-03-26 11:23:43 +01:00
|
|
|
subtitle = tr.statisticsReviewsCountSubtitle();
|
2020-06-28 07:23:36 +02:00
|
|
|
}
|
2020-06-27 04:35:13 +02:00
|
|
|
</script>
|
|
|
|
|
2021-03-21 13:47:52 +01:00
|
|
|
<Graph {title} {subtitle}>
|
|
|
|
<InputBox>
|
2020-11-01 05:26:58 +01:00
|
|
|
<label> <input type="checkbox" bind:checked={showTime} /> {time} </label>
|
2020-06-27 04:35:13 +02:00
|
|
|
|
2021-03-26 11:23:43 +01:00
|
|
|
<GraphRangeRadios bind:graphRange {revlogRange} followRevlog={true} />
|
2021-03-21 13:47:52 +01:00
|
|
|
</InputBox>
|
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}
|
2021-03-21 10:50:35 +01:00
|
|
|
<CumulativeOverlay />
|
2021-03-21 10:58:39 +01:00
|
|
|
<HoverColumns />
|
2020-06-27 04:35:13 +02:00
|
|
|
<AxisTicks {bounds} />
|
2021-03-26 11:23:43 +01:00
|
|
|
<NoDataOverlay {bounds} />
|
2020-06-27 04:35:13 +02:00
|
|
|
</svg>
|
|
|
|
|
2021-03-26 11:23:43 +01:00
|
|
|
<TableData {tableData} />
|
2021-03-21 13:47:52 +01:00
|
|
|
</Graph>
|