Change colors of Reviews graph
This commit is contained in:
parent
318cc01c73
commit
d780c96b28
@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
import pb from "anki/backend_proto";
|
import pb from "anki/backend_proto";
|
||||||
import {
|
import {
|
||||||
interpolateBlues,
|
|
||||||
interpolateGreens,
|
interpolateGreens,
|
||||||
interpolateReds,
|
interpolateReds,
|
||||||
interpolateOranges,
|
interpolateOranges,
|
||||||
|
interpolatePurples,
|
||||||
} from "d3-scale-chromatic";
|
} from "d3-scale-chromatic";
|
||||||
import "d3-transition";
|
import "d3-transition";
|
||||||
import { select, mouse } from "d3-selection";
|
import { select, mouse } from "d3-selection";
|
||||||
@ -26,10 +26,10 @@ import { timeSpan, dayLabel } from "anki/time";
|
|||||||
import type { I18n } from "anki/i18n";
|
import type { I18n } from "anki/i18n";
|
||||||
|
|
||||||
interface Reviews {
|
interface Reviews {
|
||||||
mature: number;
|
|
||||||
young: number;
|
|
||||||
learn: number;
|
learn: number;
|
||||||
relearn: number;
|
relearn: number;
|
||||||
|
young: number;
|
||||||
|
mature: number;
|
||||||
early: number;
|
early: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +61,14 @@ export function gatherData(data: pb.BackendProto.GraphsOut): GraphData {
|
|||||||
reviewTime.get(day) ?? reviewTime.set(day, { ...empty }).get(day)!;
|
reviewTime.get(day) ?? reviewTime.set(day, { ...empty }).get(day)!;
|
||||||
|
|
||||||
switch (review.reviewKind) {
|
switch (review.reviewKind) {
|
||||||
|
case ReviewKind.LEARNING:
|
||||||
|
countEntry.learn += 1;
|
||||||
|
timeEntry.learn += review.takenMillis;
|
||||||
|
break;
|
||||||
|
case ReviewKind.RELEARNING:
|
||||||
|
countEntry.relearn += 1;
|
||||||
|
timeEntry.relearn += review.takenMillis;
|
||||||
|
break;
|
||||||
case ReviewKind.REVIEW:
|
case ReviewKind.REVIEW:
|
||||||
if (review.lastInterval < 21) {
|
if (review.lastInterval < 21) {
|
||||||
countEntry.young += 1;
|
countEntry.young += 1;
|
||||||
@ -70,14 +78,6 @@ export function gatherData(data: pb.BackendProto.GraphsOut): GraphData {
|
|||||||
timeEntry.mature += review.takenMillis;
|
timeEntry.mature += review.takenMillis;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ReviewKind.LEARNING:
|
|
||||||
countEntry.learn += 1;
|
|
||||||
timeEntry.learn += review.takenMillis;
|
|
||||||
break;
|
|
||||||
case ReviewKind.RELEARNING:
|
|
||||||
countEntry.relearn += 1;
|
|
||||||
timeEntry.relearn += review.takenMillis;
|
|
||||||
break;
|
|
||||||
case ReviewKind.EARLY_REVIEW:
|
case ReviewKind.EARLY_REVIEW:
|
||||||
countEntry.early += 1;
|
countEntry.early += 1;
|
||||||
timeEntry.early += review.takenMillis;
|
timeEntry.early += review.takenMillis;
|
||||||
@ -91,10 +91,10 @@ export function gatherData(data: pb.BackendProto.GraphsOut): GraphData {
|
|||||||
function totalsForBin(bin: BinType): number[] {
|
function totalsForBin(bin: BinType): number[] {
|
||||||
const total = [0, 0, 0, 0, 0];
|
const total = [0, 0, 0, 0, 0];
|
||||||
for (const entry of bin) {
|
for (const entry of bin) {
|
||||||
total[0] += entry[1].mature;
|
total[0] += entry[1].learn;
|
||||||
total[1] += entry[1].young;
|
total[1] += entry[1].relearn;
|
||||||
total[2] += entry[1].learn;
|
total[2] += entry[1].young;
|
||||||
total[3] += entry[1].relearn;
|
total[3] += entry[1].mature;
|
||||||
total[4] += entry[1].early;
|
total[4] += entry[1].early;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,15 +204,15 @@ export function renderReviews(
|
|||||||
const lighterGreens = scaleSequential((n) =>
|
const lighterGreens = scaleSequential((n) =>
|
||||||
interpolateGreens(cappedRange(n)!)
|
interpolateGreens(cappedRange(n)!)
|
||||||
).domain(x.domain() as any);
|
).domain(x.domain() as any);
|
||||||
const blues = scaleSequential((n) => interpolateBlues(cappedRange(n)!)).domain(
|
|
||||||
x.domain() as any
|
|
||||||
);
|
|
||||||
const reds = scaleSequential((n) => interpolateReds(cappedRange(n)!)).domain(
|
const reds = scaleSequential((n) => interpolateReds(cappedRange(n)!)).domain(
|
||||||
x.domain() as any
|
x.domain() as any
|
||||||
);
|
);
|
||||||
const oranges = scaleSequential((n) => interpolateOranges(cappedRange(n)!)).domain(
|
const oranges = scaleSequential((n) => interpolateOranges(cappedRange(n)!)).domain(
|
||||||
x.domain() as any
|
x.domain() as any
|
||||||
);
|
);
|
||||||
|
const purples = scaleSequential((n) => interpolatePurples(cappedRange(n)!)).domain(
|
||||||
|
x.domain() as any
|
||||||
|
);
|
||||||
|
|
||||||
function valueLabel(n: number): string {
|
function valueLabel(n: number): string {
|
||||||
if (showTime) {
|
if (showTime) {
|
||||||
@ -229,27 +229,27 @@ export function renderReviews(
|
|||||||
let buf = `<table><tr><td>${day}</td><td align=right>${dayTotal}</td></tr>`;
|
let buf = `<table><tr><td>${day}</td><td align=right>${dayTotal}</td></tr>`;
|
||||||
const lines = [
|
const lines = [
|
||||||
[
|
[
|
||||||
darkerGreens(1),
|
oranges(1),
|
||||||
i18n.tr(i18n.TR.STATISTICS_COUNTS_MATURE_CARDS),
|
|
||||||
valueLabel(totals[0]),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
lighterGreens(1),
|
|
||||||
i18n.tr(i18n.TR.STATISTICS_COUNTS_YOUNG_CARDS),
|
|
||||||
valueLabel(totals[1]),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
blues(1),
|
|
||||||
i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS),
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS),
|
||||||
valueLabel(totals[2]),
|
valueLabel(totals[0]),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
reds(1),
|
reds(1),
|
||||||
i18n.tr(i18n.TR.STATISTICS_COUNTS_RELEARNING_CARDS),
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_RELEARNING_CARDS),
|
||||||
|
valueLabel(totals[1]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
lighterGreens(1),
|
||||||
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_YOUNG_CARDS),
|
||||||
|
valueLabel(totals[2]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
darkerGreens(1),
|
||||||
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_MATURE_CARDS),
|
||||||
valueLabel(totals[3]),
|
valueLabel(totals[3]),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
oranges(1),
|
purples(1),
|
||||||
i18n.tr(i18n.TR.STATISTICS_COUNTS_EARLY_CARDS),
|
i18n.tr(i18n.TR.STATISTICS_COUNTS_EARLY_CARDS),
|
||||||
valueLabel(totals[4]),
|
valueLabel(totals[4]),
|
||||||
],
|
],
|
||||||
@ -274,15 +274,15 @@ export function renderReviews(
|
|||||||
.attr("fill", (d: any) => {
|
.attr("fill", (d: any) => {
|
||||||
switch (idx) {
|
switch (idx) {
|
||||||
case 0:
|
case 0:
|
||||||
return darkerGreens(d.x0);
|
|
||||||
case 1:
|
|
||||||
return lighterGreens(d.x0);
|
|
||||||
case 2:
|
|
||||||
return blues(d.x0);
|
|
||||||
case 3:
|
|
||||||
return reds(d.x0);
|
|
||||||
case 4:
|
|
||||||
return oranges(d.x0);
|
return oranges(d.x0);
|
||||||
|
case 1:
|
||||||
|
return reds(d.x0);
|
||||||
|
case 2:
|
||||||
|
return lighterGreens(d.x0);
|
||||||
|
case 3:
|
||||||
|
return darkerGreens(d.x0);
|
||||||
|
case 4:
|
||||||
|
return purples(d.x0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user