From 19a3319acfc1e88dd8a66cd0f03386e394174ac4 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Tue, 18 Sep 2018 10:30:47 -0700 Subject: [PATCH] [bugfix] Fix percent metric display and check for string columns in table (#5917) * fix percent metric display * add empty line * address string or number check --- superset/assets/src/visualizations/table.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/superset/assets/src/visualizations/table.js b/superset/assets/src/visualizations/table.js index a875aad655..2b20a7da1f 100644 --- a/superset/assets/src/visualizations/table.js +++ b/superset/assets/src/visualizations/table.js @@ -46,6 +46,7 @@ const propTypes = { }; const formatValue = d3.format('0,000'); +const formatPercent = d3.format('.3p'); function NOOP() {} function TableVis(element, props) { @@ -76,7 +77,7 @@ function TableVis(element, props) { // Add percent metrics .concat((percentMetrics || []).map(m => '%' + m)) // Removing metrics (aggregates) that are strings - .filter(m => !Number.isNaN(data[0][m])); + .filter(m => (typeof data[0][m]) === 'number'); function col(c) { const arr = []; @@ -131,9 +132,11 @@ function TableVis(element, props) { } if (isMetric) { html = d3.format(format || '0.3s')(val); - } else if (key[0] === '%') { - html = d3.format('.3p')(val); } + if (key[0] === '%') { + html = formatPercent(val); + } + return { col: key, val,