mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix(plugin-chart-table): Invalid d3Formatter on String column (#23515)
This commit is contained in:
parent
80d1e4ffa3
commit
5d910aa2e2
@ -119,6 +119,7 @@ const processColumns = memoizeOne(function processColumns(
|
|||||||
const isMetric = metricsSet.has(key) && isNumeric(key, records);
|
const isMetric = metricsSet.has(key) && isNumeric(key, records);
|
||||||
const isPercentMetric = percentMetricsSet.has(key);
|
const isPercentMetric = percentMetricsSet.has(key);
|
||||||
const isTime = dataType === GenericDataType.TEMPORAL;
|
const isTime = dataType === GenericDataType.TEMPORAL;
|
||||||
|
const isNumber = dataType === GenericDataType.NUMERIC;
|
||||||
const savedFormat = columnFormats?.[key];
|
const savedFormat = columnFormats?.[key];
|
||||||
const numberFormat = config.d3NumberFormat || savedFormat;
|
const numberFormat = config.d3NumberFormat || savedFormat;
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ const processColumns = memoizeOne(function processColumns(
|
|||||||
} else if (isPercentMetric) {
|
} else if (isPercentMetric) {
|
||||||
// percent metrics have a default format
|
// percent metrics have a default format
|
||||||
formatter = getNumberFormatter(numberFormat || PERCENT_3_POINT);
|
formatter = getNumberFormatter(numberFormat || PERCENT_3_POINT);
|
||||||
} else if (isMetric || numberFormat) {
|
} else if (isMetric || (isNumber && numberFormat)) {
|
||||||
formatter = getNumberFormatter(numberFormat);
|
formatter = getNumberFormatter(numberFormat);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -97,6 +97,7 @@ describe('plugin-chart-table', () => {
|
|||||||
// should successful rerender with new props
|
// should successful rerender with new props
|
||||||
const cells = tree.find('td');
|
const cells = tree.find('td');
|
||||||
expect(tree.find('th').eq(1).text()).toEqual('Sum of Num');
|
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(2).text()).toEqual('12.346%');
|
||||||
expect(cells.eq(4).text()).toEqual('2.47k');
|
expect(cells.eq(4).text()).toEqual('2.47k');
|
||||||
});
|
});
|
||||||
|
@ -144,6 +144,20 @@ const advanced: TableChartProps = {
|
|||||||
...basicFormData,
|
...basicFormData,
|
||||||
metrics: ['sum__num'],
|
metrics: ['sum__num'],
|
||||||
percent_metrics: ['pct_nice'],
|
percent_metrics: ['pct_nice'],
|
||||||
|
column_config: {
|
||||||
|
name: {
|
||||||
|
d3NumberFormat: '.3s',
|
||||||
|
},
|
||||||
|
sum__num: {
|
||||||
|
d3NumberFormat: '.3s',
|
||||||
|
},
|
||||||
|
pct_nice: {
|
||||||
|
d3NumberFormat: '.3s',
|
||||||
|
},
|
||||||
|
'abc.com': {
|
||||||
|
d3NumberFormat: '.3s',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
queriesData: [
|
queriesData: [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user