Skip to content

Commit

Permalink
[bugfix] Fix percent metric display and check for string columns in t…
Browse files Browse the repository at this point in the history
…able (apache#5917)

* fix percent metric display

* add empty line

* address string or number check
  • Loading branch information
kristw authored and betodealmeida committed Oct 12, 2018
1 parent 5f19364 commit b50170e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions superset/assets/src/visualizations/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const propTypes = {
};

const formatValue = d3.format('0,000');
const formatPercent = d3.format('.3p');
function NOOP() {}

function TableVis(element, props) {
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b50170e

Please sign in to comment.