From fcd3b7e43cd3c17691bbe7b5652dd6cad559822d Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Fri, 1 Dec 2023 12:56:44 +0100 Subject: [PATCH] fix: Y can be NaN (columns) --- app/charts/column/columns-state.tsx | 4 +++- app/charts/column/columns.tsx | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/charts/column/columns-state.tsx b/app/charts/column/columns-state.tsx index 4666ba3138..424142ba80 100644 --- a/app/charts/column/columns-state.tsx +++ b/app/charts/column/columns-state.tsx @@ -235,6 +235,8 @@ const useColumnsState = ( return `${getYError(d)}${yErrorMeasure?.unit ?? ""}`; }; + const y = getY(d); + return { xAnchor, yAnchor, @@ -246,7 +248,7 @@ const useColumnsState = ( xValue: xTimeUnit ? timeFormatUnit(xLabel, xTimeUnit) : xLabel, datum: { label: undefined, - value: `${yValueFormatter(getY(d))}`, + value: y !== null && isNaN(y) ? "-" : `${yValueFormatter(getY(d))}`, error: getError(d), color: "", }, diff --git a/app/charts/column/columns.tsx b/app/charts/column/columns.tsx index 11661ffda6..b133f8730b 100644 --- a/app/charts/column/columns.tsx +++ b/app/charts/column/columns.tsx @@ -96,7 +96,8 @@ export const Columns = () => { return chartData.map((d) => { const key = getRenderingKey(d); const xScaled = xScale(getX(d)) as number; - const y = getY(d) ?? NaN; + const yRaw = getY(d); + const y = yRaw === null || isNaN(yRaw) ? 0 : yRaw; const yScaled = yScale(y); const yRender = yScale(Math.max(y, 0)); const height = Math.abs(yScaled - y0);