X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=4316ac387153e77491abcec8e568edb351219ff3;hb=e321ff2a4d3adfb640735f26c3eda1022e9e5f14;hp=c1a9bced47ae35c1bdb5cd098a6423e493fb57f8;hpb=5ca15c05928cb263d9f43c8ce2fb3fb67f124ad4;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index c1a9bce..4316ac3 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2335,7 +2335,9 @@ Dygraph.prototype.gatherDatasets_ = function(rolledSeries, dateWindow) { series[j][1][2]]; } } else if (this.attr_("stackedGraph")) { - var actual_y, last_x; + // Need to clear last_x explicitly as javascript's locals are + // local to function, not to a block of statements + var actual_y, last_x = null; for (j = 0; j < series.length; j++) { // If one data set has a NaN, let all subsequent stacked // sets inherit the NaN -- only start at 0 for the first set. @@ -2350,7 +2352,7 @@ Dygraph.prototype.gatherDatasets_ = function(rolledSeries, dateWindow) { continue; } - if (j === 0 || last_x != x) { + if (last_x != x) { cumulative_y[x] += actual_y; // If an x-value is repeated, we ignore the duplicates. }