You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ju...@apache.org on 2023/03/28 22:25:44 UTC
[superset] branch master updated: fix(plugin-chart-table): Invalid d3Formatter on String column (#23515)
This is an automated email from the ASF dual-hosted git repository.
justinpark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 5d910aa2e2 fix(plugin-chart-table): Invalid d3Formatter on String column (#23515)
5d910aa2e2 is described below
commit 5d910aa2e248edcee055f715def9b02bc2c1d62b
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Tue Mar 28 15:25:35 2023 -0700
fix(plugin-chart-table): Invalid d3Formatter on String column (#23515)
---
.../plugins/plugin-chart-table/src/transformProps.ts | 3 ++-
.../plugins/plugin-chart-table/test/TableChart.test.tsx | 1 +
.../plugins/plugin-chart-table/test/testData.ts | 14 ++++++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts b/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
index 2fae16c31c..df59d89f09 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
@@ -119,6 +119,7 @@ const processColumns = memoizeOne(function processColumns(
const isMetric = metricsSet.has(key) && isNumeric(key, records);
const isPercentMetric = percentMetricsSet.has(key);
const isTime = dataType === GenericDataType.TEMPORAL;
+ const isNumber = dataType === GenericDataType.NUMERIC;
const savedFormat = columnFormats?.[key];
const numberFormat = config.d3NumberFormat || savedFormat;
@@ -151,7 +152,7 @@ const processColumns = memoizeOne(function processColumns(
} else if (isPercentMetric) {
// percent metrics have a default format
formatter = getNumberFormatter(numberFormat || PERCENT_3_POINT);
- } else if (isMetric || numberFormat) {
+ } else if (isMetric || (isNumber && numberFormat)) {
formatter = getNumberFormatter(numberFormat);
}
return {
diff --git a/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx b/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
index d8d76b5c8f..1e699b6888 100644
--- a/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
@@ -97,6 +97,7 @@ describe('plugin-chart-table', () => {
// should successful rerender with new props
const cells = tree.find('td');
expect(tree.find('th').eq(1).text()).toEqual('Sum of Num');
+ expect(cells.eq(0).text()).toEqual('Michael');
expect(cells.eq(2).text()).toEqual('12.346%');
expect(cells.eq(4).text()).toEqual('2.47k');
});
diff --git a/superset-frontend/plugins/plugin-chart-table/test/testData.ts b/superset-frontend/plugins/plugin-chart-table/test/testData.ts
index f617ce8a1f..9896e7bf49 100644
--- a/superset-frontend/plugins/plugin-chart-table/test/testData.ts
+++ b/superset-frontend/plugins/plugin-chart-table/test/testData.ts
@@ -144,6 +144,20 @@ const advanced: TableChartProps = {
...basicFormData,
metrics: ['sum__num'],
percent_metrics: ['pct_nice'],
+ column_config: {
+ name: {
+ d3NumberFormat: '.3s',
+ },
+ sum__num: {
+ d3NumberFormat: '.3s',
+ },
+ pct_nice: {
+ d3NumberFormat: '.3s',
+ },
+ 'abc.com': {
+ d3NumberFormat: '.3s',
+ },
+ },
},
queriesData: [
{