superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Avoid dividing by zero for sparkline in time table viz (#3679)
Date Mon, 16 Oct 2017 23:31:09 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin 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 ce5fa37  Avoid dividing by zero for sparkline in time table viz (#3679)
ce5fa37 is described below

commit ce5fa379ec4ef182ee119f37e1675ee752de8f3c
Author: michellethomas <michelle.q.thomas@gmail.com>
AuthorDate: Mon Oct 16 16:31:07 2017 -0700

    Avoid dividing by zero for sparkline in time table viz (#3679)
---
 superset/assets/visualizations/time_table.jsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/superset/assets/visualizations/time_table.jsx b/superset/assets/visualizations/time_table.jsx
index 4a6e179..9b687f1 100644
--- a/superset/assets/visualizations/time_table.jsx
+++ b/superset/assets/visualizations/time_table.jsx
@@ -72,7 +72,12 @@ function viz(slice, payload) {
           // Period ratio sparkline
           sparkData = [];
           for (let i = c.timeRatio; i < data.length; i++) {
-            sparkData.push(data[i][metric] / data[i - c.timeRatio][metric]);
+            const prevData = data[i - c.timeRatio][metric];
+            if (prevData && prevData !== 0) {
+              sparkData.push(data[i][metric] / prevData);
+            } else {
+              sparkData.push(null);
+            }
           }
         }
         const extent = d3.extent(sparkData);

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <commits@superset.apache.org>'].

Mime
View raw message