fix(charts): drop duplicate y-axis ticks on narrow weight domains

When the visible Y-domain spans less than ~6 units the chart's
integer tick formatter rounded two adjacent gridlines to the same
label — '83 kg' appeared twice on /insights/gewicht when the
domain ran from 82.3 to 85.1. Promote the formatter to a one-
decimal projection when the domain is narrow so each tick reads
distinct without inflating the BP / glucose / steps axes where
integers are correct.

Per .planning/round-v1433-audit-runtime.md F10.
This commit is contained in:
Marc-André Bombeck committed 2026-05-16 17:13:21 +02:00
1 parent 9c738b601b
commit 13b2c13caf
1 file changed
+11 -2
+11 -2
View File
@@ -961,7 +961,16 @@ export function HealthChart({
return zones;
}, [showBands, targetZones, yDomain]);
const formatAxisValue = (value: number) => fmt.integer(value);
// v1.4.33 F10 — preserve one decimal when the visible Y-domain span is
// narrow enough that two distinct gridlines would otherwise round to
// the same integer (e.g. weight at 82.8 vs 83.5 both rendering as
// "83 kg"). The threshold matches the body-composition cluster: any
// domain spanning < 6 units gets `0.1`-precision ticks; wider domains
// keep the integer formatter so BP / glucose / steps stay clean.
const yDomainSpan = yDomain ? yDomain[1] - yDomain[0] : null;
const useDecimalAxis = yDomainSpan !== null && yDomainSpan < 6;
const formatAxisValue = (value: number) =>
useDecimalAxis ? fmt.number(value, 1) : fmt.integer(value);
const formatTooltipValue = (value: number) => fmt.number(value, 1);
@@ -1313,7 +1322,7 @@ export function HealthChart({
domain={yDomain}
tickFormatter={(value) =>
typeof value === "number"
? formatAxisValue(Math.round(value))
? formatAxisValue(useDecimalAxis ? value : Math.round(value))
: String(value)
}
unit={