You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2022/09/20 20:50:15 UTC

[superset] 05/29: Big Number Viz: (#20946)

This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch 2.0-test
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 6a5b12ec8c703404c922ce5fd62662c02a6c7460
Author: Antonio Rivero Martinez <38...@users.noreply.github.com>
AuthorDate: Wed Aug 3 12:12:56 2022 -0300

    Big Number Viz: (#20946)
    
    - When the value is zero we still render the percent change and suffix if present
    
    (cherry picked from commit aa53c1031215ece0fec7dd798ab113a3e012d910)
---
 .../src/BigNumber/BigNumberWithTrendline/transformProps.ts          | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
index faf6271302..07ca77547b 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
@@ -125,8 +125,10 @@ export default function transformProps(
       if (compareIndex < sortedData.length) {
         const compareValue = sortedData[compareIndex][1];
         // compare values must both be non-nulls
-        if (bigNumber !== null && compareValue !== null && compareValue !== 0) {
-          percentChange = (bigNumber - compareValue) / Math.abs(compareValue);
+        if (bigNumber !== null && compareValue !== null) {
+          percentChange = compareValue
+            ? (bigNumber - compareValue) / Math.abs(compareValue)
+            : 0;
           formattedSubheader = `${formatPercentChange(
             percentChange,
           )} ${compareSuffix}`;