X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-layout.js;h=9a0ac3d29c74a085c11b039825f1cde8343ec56e;hb=0815ea828a3ec9bb9474eea7aaab954baac778c2;hp=e25afba213b437103db9355693f204154890dc63;hpb=f34f95d1f2fe3adcc0bbe578368740afba513d9f;p=dygraphs.git diff --git a/dygraph-layout.js b/dygraph-layout.js index e25afba..9a0ac3d 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -277,7 +277,7 @@ DygraphLayout.parseFloat_ = function(val) { // Assume it's a number or NaN. If it's something else, I'll be shocked. return val; -} +}; DygraphLayout.prototype._evaluateLineTicks = function() { var i, tick, label, pos; @@ -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;