Satisfy formatter
This commit is contained in:
parent
9e0984fee1
commit
2ae09ae39e
@ -4,7 +4,7 @@
|
|||||||
import type { GraphData, TableDatum } from "./card-counts";
|
import type { GraphData, TableDatum } from "./card-counts";
|
||||||
import type pb from "anki/backend_proto";
|
import type pb from "anki/backend_proto";
|
||||||
import type { I18n } from "anki/i18n";
|
import type { I18n } from "anki/i18n";
|
||||||
import CountMethodRadios from './CountMethodRadios.svelte';
|
import CountMethodRadios from "./CountMethodRadios.svelte";
|
||||||
|
|
||||||
export let sourceData: pb.BackendProto.GraphsOut;
|
export let sourceData: pb.BackendProto.GraphsOut;
|
||||||
export let i18n: I18n;
|
export let i18n: I18n;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import { CardQueue, CardType } from "anki/cards";
|
import { CardQueue, CardType } from "anki/cards";
|
||||||
import type pb from "anki/backend_proto";
|
import type pb from "anki/backend_proto";
|
||||||
import { schemeGreens, schemeBlues, schemeOranges} from "d3-scale-chromatic";
|
import { schemeGreens, schemeBlues, schemeOranges } from "d3-scale-chromatic";
|
||||||
import "d3-transition";
|
import "d3-transition";
|
||||||
import { select } from "d3-selection";
|
import { select } from "d3-selection";
|
||||||
import { scaleLinear } from "d3-scale";
|
import { scaleLinear } from "d3-scale";
|
||||||
@ -35,7 +35,7 @@ const barColours = {
|
|||||||
relearn: schemeOranges[5][3],
|
relearn: schemeOranges[5][3],
|
||||||
suspended: "#FFDC41",
|
suspended: "#FFDC41",
|
||||||
buried: "grey",
|
buried: "grey",
|
||||||
}
|
};
|
||||||
|
|
||||||
function gatherByQueue(cards: pb.BackendProto.ICard[], i18n: I18n): Count[] {
|
function gatherByQueue(cards: pb.BackendProto.ICard[], i18n: I18n): Count[] {
|
||||||
let newCards = 0;
|
let newCards = 0;
|
||||||
@ -51,7 +51,7 @@ function gatherByQueue(cards: pb.BackendProto.ICard[], i18n: I18n): Count[] {
|
|||||||
break;
|
break;
|
||||||
case CardQueue.Review:
|
case CardQueue.Review:
|
||||||
review += 1;
|
review += 1;
|
||||||
break
|
break;
|
||||||
case CardQueue.Learn:
|
case CardQueue.Learn:
|
||||||
case CardQueue.DayLearn:
|
case CardQueue.DayLearn:
|
||||||
case CardQueue.PreviewRepeat:
|
case CardQueue.PreviewRepeat:
|
||||||
@ -71,7 +71,11 @@ function gatherByQueue(cards: pb.BackendProto.ICard[], i18n: I18n): Count[] {
|
|||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_NEW_CARDS), newCards, barColours.new],
|
[i18n.tr(i18n.TR.STATISTICS_COUNTS_NEW_CARDS), newCards, barColours.new],
|
||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS), learn, barColours.learn],
|
[i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS), learn, barColours.learn],
|
||||||
["Review", review, barColours.review],
|
["Review", review, barColours.review],
|
||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_SUSPENDED_CARDS), suspended, barColours.suspended],
|
[
|
||||||
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_SUSPENDED_CARDS),
|
||||||
|
suspended,
|
||||||
|
barColours.suspended,
|
||||||
|
],
|
||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_BURIED_CARDS), buried, barColours.buried],
|
[i18n.tr(i18n.TR.STATISTICS_COUNTS_BURIED_CARDS), buried, barColours.buried],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -96,14 +100,13 @@ function gatherByCtype(cards: pb.BackendProto.ICard[], i18n: I18n): Count[] {
|
|||||||
case CardType.Review:
|
case CardType.Review:
|
||||||
if (card.interval < 21) {
|
if (card.interval < 21) {
|
||||||
young += 1;
|
young += 1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mature += 1;
|
mature += 1;
|
||||||
}
|
}
|
||||||
break
|
break;
|
||||||
case CardType.Relearn:
|
case CardType.Relearn:
|
||||||
relearn += 1;
|
relearn += 1;
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,17 +115,26 @@ function gatherByCtype(cards: pb.BackendProto.ICard[], i18n: I18n): Count[] {
|
|||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS), learn, barColours.learn],
|
[i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS), learn, barColours.learn],
|
||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_YOUNG_CARDS), young, barColours.young],
|
[i18n.tr(i18n.TR.STATISTICS_COUNTS_YOUNG_CARDS), young, barColours.young],
|
||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_MATURE_CARDS), mature, barColours.mature],
|
[i18n.tr(i18n.TR.STATISTICS_COUNTS_MATURE_CARDS), mature, barColours.mature],
|
||||||
[i18n.tr(i18n.TR.STATISTICS_COUNTS_RELEARNING_CARDS), relearn, barColours.relearn],
|
[
|
||||||
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_RELEARNING_CARDS),
|
||||||
|
relearn,
|
||||||
|
barColours.relearn,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return counts;
|
return counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function gatherData(data: pb.BackendProto.GraphsOut, method: CardCountMethod, i18n: I18n): GraphData {
|
export function gatherData(
|
||||||
|
data: pb.BackendProto.GraphsOut,
|
||||||
|
method: CardCountMethod,
|
||||||
|
i18n: I18n
|
||||||
|
): GraphData {
|
||||||
const totalCards = data.cards.length;
|
const totalCards = data.cards.length;
|
||||||
const counts = method === CardCountMethod.ByType
|
const counts =
|
||||||
? gatherByCtype(data.cards, i18n)
|
method === CardCountMethod.ByType
|
||||||
: gatherByQueue(data.cards, i18n);
|
? gatherByCtype(data.cards, i18n)
|
||||||
|
: gatherByQueue(data.cards, i18n);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: i18n.tr(i18n.TR.STATISTICS_COUNTS_TITLE),
|
title: i18n.tr(i18n.TR.STATISTICS_COUNTS_TITLE),
|
||||||
@ -197,17 +209,18 @@ export function renderCards(
|
|||||||
function (update) {
|
function (update) {
|
||||||
return update.call((d) =>
|
return update.call((d) =>
|
||||||
d
|
d
|
||||||
.transition(trans)
|
.transition(trans)
|
||||||
.attr("fill", (_d, i) => {
|
.attr("fill", (_d, i) => {
|
||||||
return data[i].colour;
|
return data[i].colour;
|
||||||
})
|
})
|
||||||
.attrTween("d", (d) => {
|
.attrTween("d", (d) => {
|
||||||
const interpolator = interpolate(
|
const interpolator = interpolate(
|
||||||
{ startAngle: 0, endAngle: 0 },
|
{ startAngle: 0, endAngle: 0 },
|
||||||
d,
|
d
|
||||||
);
|
);
|
||||||
return (t): string => arcGen(interpolator(t) as any) as string;
|
return (t): string =>
|
||||||
})
|
arcGen(interpolator(t) as any) as string;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user