fix(labs): keep the biomarker chart axis at zero for a range starting at zero

A reference window of 0-130 padded the axis to -13, a tick that reads
like a value for a concentration that cannot be negative. The pad only
goes below zero when the data already does.
This commit is contained in:
Marc-André Bombeck committed 2026-10-01 09:44:30 +02:00
1 parent 4a13004917
commit 24e6972f95
1 file changed
+4 -1
+4 -1
View File
@@ -163,7 +163,10 @@ export function LabBiomarkerChart({
const min = Math.min(...candidates);
const max = Math.max(...candidates);
const pad = (max - min || Math.abs(max) || 1) * 0.1;
return [min - pad, max + pad];
// A reference window that starts at 0 (LDL "0–130") must not drag the
// axis below zero: a concentration cannot be negative, and a "-13" tick
// reads as a value. The pad only stays below zero when the data already is.
return [min >= 0 ? Math.max(0, min - pad) : min - pad, max + pad];
}, [points, lowerBound, upperBound, sourceBand]);
const animate = !prefersReducedMotion();