[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
This commit is contained in:
Krist Wongsuphasawat 2018-09-18 10:30:47 -07:00 committed by Grace Guo
parent f2d64492ef
commit 19a3319acf
1 changed files with 6 additions and 3 deletions

View File

@ -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,