X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-layout.js;h=9a0ac3d29c74a085c11b039825f1cde8343ec56e;hb=0815ea828a3ec9bb9474eea7aaab954baac778c2;hp=7e08e3e1120cb732e7ea91111edfb494ce8f7fb5;hpb=42a9ebb8f492d2541a3904894447a7c74ba4cfd5;p=dygraphs.git diff --git a/dygraph-layout.js b/dygraph-layout.js index 7e08e3e..9a0ac3d 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -409,12 +409,15 @@ DygraphLayout.prototype.unstackPointAtIndex = function(setIdx, row) { // The unstacked yval is equal to the current yval minus the yval of the // next point at the same xval. - var points = this.points[setIdx]; - for (var i = row + 1; i < points.length; i++) { - if ((points[i].xval == point.xval) && points[i].yval) { - unstackedPoint.yval -= points[i].yval; - break; - } + if (setIdx == this.points.length - 1) { + // We're the last series, so no unstacking is necessary. + return unstackedPoint; + } + + var points = this.points[setIdx + 1]; + if (points[row].xval == point.xval && // should always be true? + points[row].yval) { + unstackedPoint.yval -= points[row].yval; } return unstackedPoint;