From 68c69f67cee29faeb7d13e75bff9b95e70823976 Mon Sep 17 00:00:00 2001 From: ayeshaa-m <126784820+ayeshaa-m@users.noreply.github.com> Date: Wed, 17 May 2023 09:21:11 +0530 Subject: [PATCH] fix(grid-cell): resolve floating point precision issue (#1839) --- .../src/components/data-grid/cell-handlers/graph-cell.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/components/src/components/data-grid/cell-handlers/graph-cell.tsx b/packages/components/src/components/data-grid/cell-handlers/graph-cell.tsx index eeafa8609a..3137a3a1d8 100644 --- a/packages/components/src/components/data-grid/cell-handlers/graph-cell.tsx +++ b/packages/components/src/components/data-grid/cell-handlers/graph-cell.tsx @@ -27,7 +27,11 @@ export const GraphCell: Cell = { const { style = 'progress', min = 0, max = 100 } = field; // Convert content to 0>100 range for progress bar - const progress = ((content - min) / (max - min)) * 100; + const progress = parseFloat( + (((content - min) / (max - min)) * 100).toPrecision( + String(content).replace('.', '').length + ) + ); switch (style) { case 'bar':