2020-07-17 05:46:06 +02:00
|
|
|
<script lang="typescript">
|
2020-11-01 05:26:58 +01:00
|
|
|
import { RevlogRange, GraphRange } from "./graph-helpers";
|
2020-11-05 02:01:30 +01:00
|
|
|
import { timeSpan, MONTH, YEAR } from "anki/time";
|
2020-07-17 05:46:06 +02:00
|
|
|
|
2021-03-26 11:23:43 +01:00
|
|
|
import * as tr from "anki/i18n";
|
2020-07-17 05:46:06 +02:00
|
|
|
export let revlogRange: RevlogRange;
|
|
|
|
export let graphRange: GraphRange;
|
2020-07-17 06:00:23 +02:00
|
|
|
export let followRevlog: boolean = false;
|
|
|
|
|
|
|
|
function onFollowRevlog(revlogRange: RevlogRange) {
|
|
|
|
if (revlogRange === RevlogRange.All) {
|
|
|
|
graphRange = GraphRange.AllTime;
|
|
|
|
} else if (graphRange === GraphRange.AllTime) {
|
|
|
|
graphRange = GraphRange.Year;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$: if (followRevlog) {
|
|
|
|
// split into separate function so svelte does not
|
|
|
|
// run this when graphRange changes
|
|
|
|
onFollowRevlog(revlogRange);
|
|
|
|
}
|
2020-07-17 05:46:06 +02:00
|
|
|
|
2021-03-26 11:23:43 +01:00
|
|
|
const month = timeSpan(1 * MONTH);
|
|
|
|
const month3 = timeSpan(3 * MONTH);
|
|
|
|
const year = timeSpan(1 * YEAR);
|
|
|
|
const all = tr.statisticsRangeAllTime();
|
2020-07-17 05:46:06 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={graphRange} value={GraphRange.Month} />
|
|
|
|
{month}
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={graphRange} value={GraphRange.ThreeMonths} />
|
|
|
|
{month3}
|
|
|
|
</label>
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={graphRange} value={GraphRange.Year} />
|
|
|
|
{year}
|
|
|
|
</label>
|
|
|
|
{#if revlogRange === RevlogRange.All}
|
|
|
|
<label>
|
|
|
|
<input type="radio" bind:group={graphRange} value={GraphRange.AllTime} />
|
|
|
|
{all}
|
|
|
|
</label>
|
|
|
|
{/if}
|