Skip to content

Commit aa53c10

Browse files
Big Number Viz: (#20946)
- When the value is zero we still render the percent change and suffix if present
1 parent 96a63bc commit aa53c10

File tree

1 file changed

+4
-2
lines changed
  • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline

1 file changed

+4
-2
lines changed

superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ export default function transformProps(
125125
if (compareIndex < sortedData.length) {
126126
const compareValue = sortedData[compareIndex][1];
127127
// compare values must both be non-nulls
128-
if (bigNumber !== null && compareValue !== null && compareValue !== 0) {
129-
percentChange = (bigNumber - compareValue) / Math.abs(compareValue);
128+
if (bigNumber !== null && compareValue !== null) {
129+
percentChange = compareValue
130+
? (bigNumber - compareValue) / Math.abs(compareValue)
131+
: 0;
130132
formattedSubheader = `${formatPercentChange(
131133
percentChange,
132134
)} ${compareSuffix}`;

0 commit comments

Comments
 (0)