Increase the daily counts chart y-axis granularity

1-unit gridlines up to 10, 2-unit up to 20, 5-unit beyond — previously
anything above 10 was squeezed into five segments.
This commit is contained in:
Alexander Heldt
2026-07-12 17:30:16 +00:00
parent 094af3906d
commit 1c4bea51df
2 changed files with 6 additions and 4 deletions
+5 -4
View File
@@ -838,19 +838,20 @@
}
// Pick a chart Y maximum and tick count so every tick label is a clean
// whole number (avoids 0, 0, 1, 1, 2 from rounding fractional steps).
// whole number (avoids 0, 0, 1, 1, 2 from rounding fractional steps):
// 1-unit gridlines up to 10, 2-unit up to 20, 5-unit beyond.
function niceAxis(rawMax) {
if (!(rawMax > 0)) return { yMax: 1, steps: 1 };
if (rawMax <= 4) {
if (rawMax <= 10) {
const m = Math.ceil(rawMax);
return { yMax: m, steps: m };
}
if (rawMax <= 10) {
if (rawMax <= 20) {
const m = Math.ceil(rawMax / 2) * 2;
return { yMax: m, steps: m / 2 };
}
const m = Math.ceil(rawMax / 5) * 5;
return { yMax: m, steps: 5 };
return { yMax: m, steps: m / 5 };
}
// Sleep-specific axis: always 2-hour granularity, capped at 24h/day,