From: Nikhil Kasinadhuni Date: Thu, 11 Mar 2010 01:10:06 +0000 (-0800) Subject: Fixed a bug with generating points for stackedGraph. X-Git-Tag: v1.0.0~702^2~5 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=d4139cd8006a7e0c5fba31a8917d16178817b4e7;p=dygraphs.git Fixed a bug with generating points for stackedGraph. --- diff --git a/dygraph.js b/dygraph.js index 3eaa18e..4fbf443 100644 --- a/dygraph.js +++ b/dygraph.js @@ -902,19 +902,20 @@ Dygraph.prototype.mouseMove_ = function(event) { this.selPoints_ = []; var cumulative_sum = 0; // used only if we have a stackedGraph. var l = points.length; - for (var i = 0; i < l; i++) { + for (var i = l - 1; i >= 0; i--) { if (points[i].xval == lastx) { if (!this.attr_("stackedGraph")) { - this.selPoints_.push(points[i]); + this.selPoints_.unshift(points[i]); } else { // Clone the point, since we need to 'unstack' it below. Stacked points // are in reverse order. var p = {}; - for (var k in points[l - i - 1]) { - p[k] = points[l - i -1][k]; + for (var k in points[i]) { + p[k] = points[i][k]; } p.yval -= cumulative_sum; cumulative_sum += p.yval; + this.selPoints_.push(p); } } }