Skip to content

Commit

Permalink
fix: Y can be NaN (columns)
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Dec 1, 2023
1 parent 9a3cd9b commit fcd3b7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/charts/column/columns-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ const useColumnsState = (
return `${getYError(d)}${yErrorMeasure?.unit ?? ""}`;
};

const y = getY(d);

return {
xAnchor,
yAnchor,
Expand All @@ -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: "",
},
Expand Down
3 changes: 2 additions & 1 deletion app/charts/column/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fcd3b7e

Please sign in to comment.