mirror of
https://github.com/ankitects/anki.git
synced 2026-01-08 03:23:54 -05:00
fixed labels for bins, and made sure year is 365 days
This commit is contained in:
parent
0c2c5c6a1c
commit
6e341d5e07
2 changed files with 9 additions and 10 deletions
|
|
@ -177,17 +177,10 @@ export function dayLabel(daysStart: number, daysEnd: number): string {
|
|||
daysStart,
|
||||
daysEnd: daysEnd - 1,
|
||||
});
|
||||
} else if (daysEnd <= 0) {
|
||||
// Past: [-10, -5) -> "5-9 days ago"
|
||||
return tr.statisticsDaysAgoRange({
|
||||
daysStart: Math.abs(daysEnd),
|
||||
daysEnd: Math.abs(daysStart) - 1,
|
||||
});
|
||||
} else {
|
||||
// Crosses zero: [-5, 1) -> "0-4 days ago"
|
||||
return tr.statisticsDaysAgoRange({
|
||||
daysStart: 0,
|
||||
daysEnd: Math.abs(daysStart) - 1,
|
||||
daysStart: Math.abs(daysEnd - 1),
|
||||
daysEnd: -daysStart,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ export function renderReviews(
|
|||
break;
|
||||
}
|
||||
const desiredBars = Math.min(70, Math.abs(xMin!));
|
||||
const shouldCapRange = range !== GraphRange.AllTime;
|
||||
const originalXMin = shouldCapRange ? xMin! : undefined;
|
||||
|
||||
// Create initial scale to determine tick spacing
|
||||
let x = scaleLinear().domain([xMin!, xMax]);
|
||||
|
|
@ -117,7 +119,11 @@ export function renderReviews(
|
|||
const spacing = thresholds[1] - thresholds[0];
|
||||
const partial = thresholds[0] - xMin!;
|
||||
if (spacing > 0 && partial > 0 && partial < spacing) {
|
||||
xMin = thresholds[0] - spacing;
|
||||
const adjustedMin = thresholds[0] - spacing;
|
||||
// Don't extend beyond the original range limit for fixed ranges
|
||||
xMin = shouldCapRange
|
||||
? Math.max(adjustedMin, originalXMin!)
|
||||
: adjustedMin;
|
||||
x = scaleLinear().domain([xMin, xMax]);
|
||||
thresholds = x.ticks(desiredBars);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue