mirror of https://github.com/apache/superset.git
[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:
parent
f2d64492ef
commit
19a3319acf
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue