mirror of
https://github.com/ankitects/anki.git
synced 2026-01-08 03:23:54 -05:00
update graph so that the tooltip day label uses integer day boundaries
This commit is contained in:
parent
5d4b00a11d
commit
e013ee61b5
4 changed files with 13 additions and 6 deletions
|
|
@ -254,6 +254,7 @@ nav1s <nav1s@proton.me>
|
||||||
Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
||||||
Eltaurus <https://github.com/Eltaurus-Lt>
|
Eltaurus <https://github.com/Eltaurus-Lt>
|
||||||
jariji
|
jariji
|
||||||
|
Junia Mannervik <junia.mannervik@gmail.com>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,9 +178,11 @@ export function dayLabel(daysStart: number, daysEnd: number): string {
|
||||||
daysEnd: daysEnd - 1,
|
daysEnd: daysEnd - 1,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
const mostRecent = daysEnd <= 0 ? Math.abs(daysEnd - 1) : 0;
|
||||||
|
const oldest = -daysStart;
|
||||||
return tr.statisticsDaysAgoRange({
|
return tr.statisticsDaysAgoRange({
|
||||||
daysStart: Math.abs(daysEnd - 1),
|
daysStart: mostRecent,
|
||||||
daysEnd: -daysStart,
|
daysEnd: oldest,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,10 @@ export function renderCalendar(
|
||||||
// don't fill out future dates
|
// don't fill out future dates
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (date.getFullYear() != targetYear) {
|
||||||
|
// only fill blanks for the target year
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (revlogRange == RevlogRange.Year && date < oneYearAgoFromNow) {
|
if (revlogRange == RevlogRange.Year && date < oneYearAgoFromNow) {
|
||||||
// don't fill out dates older than a year
|
// don't fill out dates older than a year
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,7 @@ export function renderReviews(
|
||||||
const desiredBars = Math.min(70, Math.abs(xMin!));
|
const desiredBars = Math.min(70, Math.abs(xMin!));
|
||||||
|
|
||||||
const x = scaleLinear().domain([xMin!, xMax]);
|
const x = scaleLinear().domain([xMin!, xMax]);
|
||||||
if (range === GraphRange.AllTime) {
|
|
||||||
x.nice(desiredBars);
|
|
||||||
}
|
|
||||||
|
|
||||||
const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount;
|
const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount;
|
||||||
const bins = bin()
|
const bins = bin()
|
||||||
|
|
@ -212,7 +210,9 @@ export function renderReviews(
|
||||||
}
|
}
|
||||||
|
|
||||||
function tooltipText(d: BinType, cumulative: number): string {
|
function tooltipText(d: BinType, cumulative: number): string {
|
||||||
const day = dayLabel(d.x0!, d.x1!);
|
const startDay = Math.trunc(d.x0!);
|
||||||
|
const endDay = Math.trunc(d.x1!);
|
||||||
|
const day = dayLabel(startDay, endDay);
|
||||||
const totals = totalsForBin(d);
|
const totals = totalsForBin(d);
|
||||||
const dayTotal = valueLabel(sum(totals));
|
const dayTotal = valueLabel(sum(totals));
|
||||||
let buf = `<table><tr><td>${day}</td><td align=end>${dayTotal}</td></tr>`;
|
let buf = `<table><tr><td>${day}</td><td align=end>${dayTotal}</td></tr>`;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue