Show whole-number metrics as whole numbers

The dashboard tiles printed every value at one decimal: '121,0 mmHg',
'60,0 bpm', '9.240,0' steps. TrendCard takes the metric's precision, and
blood pressure, pulse, HRV, steps and mg/dL glucose pass zero. The
measurement list names count-shaped units the way the insights pages do
('13 Etagen', '12,5 Atemzüge/min') instead of the source's 'count'.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 16:21:12 +02:00
1 parent b80dc14142
commit 554f36aeab
6 files changed
+108 -7

No files matched your search

+6 -1
View File
@@ -27,6 +27,11 @@ export function mmolToMgdl(mmol: number): number {
return Math.round(mmol * MGDL_PER_MMOL);
}
/** Decimal places a glucose value is shown at: whole mg/dL, tenths of mmol/L. */
export function glucoseFractionDigits(unit: GlucoseUnit): number {
return unit === "mmol/L" ? 1 : 0;
}
export function convertGlucose(value: number, to: GlucoseUnit): number {
return to === "mmol/L" ? mgdlToMmol(value) : Math.round(value);
}
@@ -80,7 +85,7 @@ export function glucoseBandParams(
unit: GlucoseUnit,
formatNumber: (value: number, fractionDigits: number) => string,
): Record<string, string> {
const digits = unit === "mmol/L" ? 1 : 0;
const digits = glucoseFractionDigits(unit);
const v = (point: GlucoseCutPoint) =>
formatNumber(unit === "mmol/L" ? point.mmol : point.mgdl, digits);
return {