Skip to content

Commit

Permalink
Avoid dividing by zero for sparkline in time table viz (apache#3679)
Browse files Browse the repository at this point in the history
  • Loading branch information
michellethomas committed May 23, 2018
1 parent 59037fc commit aef77d1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion superset/assets/visualizations/time_table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit aef77d1

Please sign in to comment.