update graph so that the tooltip day label uses integer day boundaries

This commit is contained in:
junlu592 2025-11-20 13:42:53 +01:00
parent 5d4b00a11d
commit e013ee61b5
4 changed files with 13 additions and 6 deletions

View file

@ -254,6 +254,7 @@ nav1s <nav1s@proton.me>
Ranjit Odedra <ranjitodedra.dev@gmail.com>
Eltaurus <https://github.com/Eltaurus-Lt>
jariji
Junia Mannervik <junia.mannervik@gmail.com>
********************

View file

@ -178,9 +178,11 @@ export function dayLabel(daysStart: number, daysEnd: number): string {
daysEnd: daysEnd - 1,
});
} else {
const mostRecent = daysEnd <= 0 ? Math.abs(daysEnd - 1) : 0;
const oldest = -daysStart;
return tr.statisticsDaysAgoRange({
daysStart: Math.abs(daysEnd - 1),
daysEnd: -daysStart,
daysStart: mostRecent,
daysEnd: oldest,
});
}
}

View file

@ -118,6 +118,10 @@ export function renderCalendar(
// don't fill out future dates
continue;
}
if (date.getFullYear() != targetYear) {
// only fill blanks for the target year
continue;
}
if (revlogRange == RevlogRange.Year && date < oneYearAgoFromNow) {
// don't fill out dates older than a year
continue;

View file

@ -111,9 +111,7 @@ export function renderReviews(
const desiredBars = Math.min(70, Math.abs(xMin!));
const x = scaleLinear().domain([xMin!, xMax]);
if (range === GraphRange.AllTime) {
x.nice(desiredBars);
}
const sourceMap = showTime ? sourceData.reviewTime : sourceData.reviewCount;
const bins = bin()
@ -212,7 +210,9 @@ export function renderReviews(
}
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 dayTotal = valueLabel(sum(totals));
let buf = `<table><tr><td>${day}</td><td align=end>${dayTotal}</td></tr>`;