fix: round numeric values to 2 decimal places in display output
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
77c9a77645
commit
f1ef8a918c
@ -154,7 +154,12 @@ export function buildDisplayJson(displayId: number): DisplayJson | null {
|
|||||||
base.text = el.static_text ?? '';
|
base.text = el.static_text ?? '';
|
||||||
} else if (el.type === 'value') {
|
} else if (el.type === 'value') {
|
||||||
base.label = el.dp_label ?? '';
|
base.label = el.dp_label ?? '';
|
||||||
base.value = el.dp_value ?? null;
|
// Round numeric values to 2 decimal places
|
||||||
|
let val = el.dp_value ?? null;
|
||||||
|
if (val != null && !isNaN(Number(val)) && val.includes('.')) {
|
||||||
|
val = parseFloat(val).toFixed(2);
|
||||||
|
}
|
||||||
|
base.value = val;
|
||||||
base.unit = el.dp_unit ?? null;
|
base.unit = el.dp_unit ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user