From d8e8dc4111c7137584a29a03f1165e64c4e50349 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Tue, 19 Mar 2019 19:01:32 -0700 Subject: [PATCH] fix: make pivot table handle null string (#23) --- .../src/PivotTable.js | 2 +- .../Stories.jsx | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-plugin-chart-pivot-table/src/PivotTable.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-plugin-chart-pivot-table/src/PivotTable.js index af0707e870ecf..f2a445793b04c 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-plugin-chart-pivot-table/src/PivotTable.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-plugin-chart-pivot-table/src/PivotTable.js @@ -71,7 +71,7 @@ function PivotTable(element, props) { const metric = cols[i]; const format = columnFormats[metric] || numberFormat || '.3s'; const tdText = $(this)[0].textContent; - if (!Number.isNaN(tdText) && tdText !== '') { + if (!Number.isNaN(tdText) && tdText !== '' && tdText.trim().toLowerCase() !== 'null') { $(this)[0].textContent = formatNumber(format, tdText); $(this).attr('data-sort', tdText); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-plugin-chart-pivot-table/Stories.jsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-plugin-chart-pivot-table/Stories.jsx index 325e03aa702c0..b532bf54c6d3b 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-plugin-chart-pivot-table/Stories.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-plugin-chart-pivot-table/Stories.jsx @@ -34,4 +34,34 @@ export default [ storyName: 'Basic', storyPath: 'legacy-|plugin-chart-pivot-table|PivotTableChartPlugin', }, + { + renderStory: () => ( + \n \n \n \n sum__num\n \n \n state\n other\n All\n \n \n name\n \n \n \n \n \n \n Christopher\n null\n 803607\n \n \n David\n null\n 673992\n \n \n James\n 749686\n null\n \n \n Jennifer\n 587540\n null\n \n \n John\n 638450\n 638450\n \n \n Joshua\n null\n 548044\n \n \n Matthew\n 608212\n 608212\n \n \n Michael\n 1047996\n 1047996\n \n \n Robert\n 575592\n 575592\n \n \n William\n 574464\n 574464\n \n \n All\n 6807583\n 6807583\n \n \n', + }, + }, + width: 400, + }} + /> + ), + storyName: 'With null', + storyPath: 'legacy-|plugin-chart-pivot-table|PivotTableChartPlugin', + }, ];