Make the food chart y-axis much finer

The grams axis now targets ~10 segments instead of ~4, so a 240 g day
gets 25 g gridlines; steps stay round numbers at any scale.
This commit is contained in:
Alexander Heldt
2026-07-13 20:52:48 +00:00
parent 695c030f33
commit cee4455651
2 changed files with 4 additions and 2 deletions
+3 -2
View File
@@ -873,9 +873,10 @@
// Grams axis: 0-based with a "nice" step so tick labels stay round whatever // Grams axis: 0-based with a "nice" step so tick labels stay round whatever
// the daily totals are (tens of grams for a tiny puppy, hundreds+ later). // the daily totals are (tens of grams for a tiny puppy, hundreds+ later).
// Aims for ~10 segments so day-to-day differences of a few grams show.
function niceAxisGrams(rawMax) { function niceAxisGrams(rawMax) {
if (!(rawMax > 0)) return { yMax: 100, steps: 2 }; if (!(rawMax > 0)) return { yMax: 100, steps: 4 };
const rawStep = rawMax / 4; const rawStep = rawMax / 10;
const mag = Math.pow(10, Math.floor(Math.log10(rawStep))); const mag = Math.pow(10, Math.floor(Math.log10(rawStep)));
const norm = rawStep / mag; const norm = rawStep / mag;
const step = (norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 2.5 ? 2.5 : norm <= 5 ? 5 : 10) * mag; const step = (norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 2.5 ? 2.5 : norm <= 5 ? 5 : 10) * mag;
+1
View File
@@ -1,4 +1,5 @@
[ [
{ "date": "2026-07-13", "text": "Much finer y-axis on the food chart" },
{ "date": "2026-07-13", "text": "The awake/asleep timer is bigger and sits first in the top bar" }, { "date": "2026-07-13", "text": "The awake/asleep timer is bigger and sits first in the top bar" },
{ "date": "2026-07-13", "text": "The sleep, daily counts and food charts now cover the last 14 days instead of 7" }, { "date": "2026-07-13", "text": "The sleep, daily counts and food charts now cover the last 14 days instead of 7" },
{ "date": "2026-07-13", "text": "The awake/asleep timer lives in the frozen top bar" }, { "date": "2026-07-13", "text": "The awake/asleep timer lives in the frozen top bar" },