From: Adam Vartanian Date: Wed, 11 Apr 2012 15:09:52 +0000 (-0400) Subject: Handle unstacking points when some points are missing properly X-Git-Tag: v1.0.0~272^2~4 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=c6bdcd600a354158117908580407ca78702697d9;p=dygraphs.git Handle unstacking points when some points are missing properly --- diff --git a/dygraph-layout.js b/dygraph-layout.js index 4938ada..8147e48 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -361,6 +361,9 @@ DygraphLayout.prototype.removeAllDatasets = function() { */ DygraphLayout.prototype.unstackPointAtIndex = function(idx) { var point = this.points[idx]; + if (!point.yval) { + return point; + } // Clone the point since we modify it var unstackedPoint = {}; @@ -375,7 +378,7 @@ DygraphLayout.prototype.unstackPointAtIndex = function(idx) { // The unstacked yval is equal to the current yval minus the yval of the // next point at the same xval. for (var i = idx+1; i < this.points.length; i++) { - if (this.points[i].xval == point.xval) { + if ((this.points[i].xval == point.xval) && this.points[i].yval) { unstackedPoint.yval -= this.points[i].yval; break; }