kristw closed pull request #5917: [bugfix] Fix percent metric display and check 
for string columns in table
URL: https://github.com/apache/incubator-superset/pull/5917
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to