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 // 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) { function niceAxis(rawMax) {
if (!(rawMax > 0)) return { yMax: 1, steps: 1 }; if (!(rawMax > 0)) return { yMax: 1, steps: 1 };
if (rawMax <= 4) { if (rawMax <= 10) {
const m = Math.ceil(rawMax); const m = Math.ceil(rawMax);
return { yMax: m, steps: m }; return { yMax: m, steps: m };
} }
if (rawMax <= 10) { if (rawMax <= 20) {
const m = Math.ceil(rawMax / 2) * 2; const m = Math.ceil(rawMax / 2) * 2;
return { yMax: m, steps: m / 2 }; return { yMax: m, steps: m / 2 };
} }
const m = Math.ceil(rawMax / 5) * 5; 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, // Sleep-specific axis: always 2-hour granularity, capped at 24h/day,
+1
View File
@@ -1,4 +1,5 @@
[ [
{ "date": "2026-07-12", "text": "Finer-grained y-axis on the daily counts chart" },
{ "date": "2026-07-12", "text": "The update banner now lists what changed in the new version" }, { "date": "2026-07-12", "text": "The update banner now lists what changed in the new version" },
{ "date": "2026-07-12", "text": "Fixed adding an exercise on iPhone: stale app updates, and the keyboard's Go key discarding the input" }, { "date": "2026-07-12", "text": "Fixed adding an exercise on iPhone: stale app updates, and the keyboard's Go key discarding the input" },
{ "date": "2026-07-12", "text": "Training: define exercises with how-to reminders, log sessions in one tap, and follow a 14-day consistency view" } { "date": "2026-07-12", "text": "Training: define exercises with how-to reminders, log sessions in one tap, and follow a 14-day consistency view" }