superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: [bugfix] Fix percent metric display and check for string columns in table (#5917)
Date Tue, 18 Sep 2018 17:30:53 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 19a3319  [bugfix] Fix percent metric display and check for string columns in table
(#5917)
19a3319 is described below

commit 19a3319acfc1e88dd8a66cd0f03386e394174ac4
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Tue Sep 18 10:30:47 2018 -0700

    [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 a875aad..2b20a7d 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,


Mime
View raw message