From 420bc1bbe845f89cec64740a25698f9e83f252e4 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 15 Apr 2026 08:54:34 -0400 Subject: [PATCH] Pivot: round numbers in inspector to 2 decimals with adjustable precision formatVal now rounds numeric values using toLocaleString with configurable decimal places (default 2, range 0-8). Adds -/+ controls in the inspector header to adjust on the fly. Co-Authored-By: Claude Sonnet 4.6 --- ui/src/pages/Pivot.jsx | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ui/src/pages/Pivot.jsx b/ui/src/pages/Pivot.jsx index f10b2be..f12ebad 100644 --- a/ui/src/pages/Pivot.jsx +++ b/ui/src/pages/Pivot.jsx @@ -30,11 +30,14 @@ function loadPerspective() { return perspectivePromise } -function formatVal(v) { +function formatVal(v, decimals = 2) { if (v == null) return null - if (typeof v === 'number' && v > 1e11 && v < 2e12) { - const d = new Date(v) - if (!isNaN(d)) return d.toISOString().slice(0, 10) + if (typeof v === 'number') { + if (v > 1e11 && v < 2e12) { + const d = new Date(v) + if (!isNaN(d)) return d.toISOString().slice(0, 10) + } + return v.toLocaleString(undefined, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }) } return String(v) } @@ -87,6 +90,7 @@ export default function Pivot({ source }) { const [error, setError] = useState('') const [inspectedRows, setInspectedRows] = useState(null) const [clickDetail, setClickDetail] = useState(null) + const [decimals, setDecimals] = useState(2) // Named layouts const [layouts, setLayouts] = useState([]) @@ -412,8 +416,17 @@ export default function Pivot({ source }) { {inspectedRows.length} row{inspectedRows.length !== 1 ? 's' : ''} - +
+
+ + {decimals} + +
+ +
@@ -434,7 +447,7 @@ export default function Pivot({ source }) { return (
{k} - {formatVal(v)} + {formatVal(v, decimals)}
) })} @@ -468,7 +481,7 @@ export default function Pivot({ source }) { {inspectedRows.map((row, i) => ( {cols.map(c => { - const f = formatVal(row[c]) + const f = formatVal(row[c], decimals) return ( {f == null ? : f}