You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by li...@apache.org on 2024/03/13 21:32:08 UTC

(superset) 01/01: fix(big-number-chart): number format is not applying to percentage number of the time comparison

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

lilykuang pushed a commit to branch big-number-percentage-format
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4899e0481dc3583f9ec1f3f47f33793c5e9a3ac5
Author: lilykuang <ji...@gmail.com>
AuthorDate: Wed Mar 13 13:38:26 2024 -0700

    fix(big-number-chart): number format is not applying to percentage number of the time comparison
---
 .../src/BigNumber/BigNumberPeriodOverPeriod/controlPanel.ts      | 9 +++++++++
 .../src/BigNumber/BigNumberPeriodOverPeriod/transformProps.ts    | 5 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/controlPanel.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/controlPanel.ts
index be731421a0..6aa54e72d2 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/controlPanel.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/controlPanel.ts
@@ -118,6 +118,15 @@ const config: ControlPanelConfig = {
       expanded: true,
       controlSetRows: [
         ['y_axis_format'],
+        [
+          {
+            name: 'percentDifferenceFormat',
+            config: {
+              ...sharedControls.y_axis_format,
+              label: t('Percent Difference format'),
+            },
+          },
+        ],
         ['currency_format'],
         [
           {
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/transformProps.ts
index ebdd16bdb1..05d188e882 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/transformProps.ts
@@ -84,6 +84,7 @@ export default function transformProps(chartProps: ChartProps) {
     currencyFormat,
     subheaderFontSize,
     comparisonColorEnabled,
+    percentDifferenceFormat,
   } = formData;
   const { data: dataA = [] } = queriesData[0];
   const {
@@ -113,9 +114,7 @@ export default function transformProps(chartProps: ChartProps) {
     w: 'Week' as string,
   };
 
-  const formatPercentChange = getNumberFormatter(
-    NumberFormats.PERCENT_SIGNED_1_POINT,
-  );
+  const formatPercentChange = getNumberFormatter(percentDifferenceFormat);
 
   let valueDifference: number | string = bigNumber - prevNumber;