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:
+3
-2
@@ -873,9 +873,10 @@
|
||||
|
||||
// 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).
|
||||
// Aims for ~10 segments so day-to-day differences of a few grams show.
|
||||
function niceAxisGrams(rawMax) {
|
||||
if (!(rawMax > 0)) return { yMax: 100, steps: 2 };
|
||||
const rawStep = rawMax / 4;
|
||||
if (!(rawMax > 0)) return { yMax: 100, steps: 4 };
|
||||
const rawStep = rawMax / 10;
|
||||
const mag = Math.pow(10, Math.floor(Math.log10(rawStep)));
|
||||
const norm = rawStep / mag;
|
||||
const step = (norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 2.5 ? 2.5 : norm <= 5 ? 5 : 10) * mag;
|
||||
|
||||
Reference in New Issue
Block a user