X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=941badb9a01edcf41444d34330d35825a1808470;hb=421427956b54e7c1bea26f6865eaf007d406a2d2;hp=2580556d2aced1722e62aa807331839184add6c2;hpb=8d9704289c9e6fab5bb88fb6a8529c83e0973742;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 2580556..941badb 100644 --- a/dygraph.js +++ b/dygraph.js @@ -993,10 +993,13 @@ Dygraph.prototype.destroy = function() { } }; - for (var idx = 0; idx < this.registeredEvents_.length; idx++) { - var reg = this.registeredEvents_[idx]; - Dygraph.removeEvent(reg.elem, reg.type, reg.fn); + if (this.registeredEvents_) { + for (var idx = 0; idx < this.registeredEvents_.length; idx++) { + var reg = this.registeredEvents_[idx]; + Dygraph.removeEvent(reg.elem, reg.type, reg.fn); + } } + this.registeredEvents_ = []; // remove mouse event handlers (This may not be necessary anymore) @@ -1282,7 +1285,7 @@ Dygraph.prototype.createDragInterface_ = function() { // This happens when the graph is resized. if (this.mouseUpHandler_) { Dygraph.removeEvent(document, 'mouseup', this.mouseUpHandler_); - }; + } // If the user releases the mouse button during a drag, but not over the // canvas, then it doesn't count as a zooming action. @@ -2500,6 +2503,10 @@ Dygraph.prototype.axisPropertiesForSeries = function(series) { * This fills in the valueRange and ticks fields in each entry of this.axes_. */ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { + + var isNullUndefinedOrNaN = function(num) { + return isNaN(parseFloat(num)); + }; var series; var numAxes = this.attributes_.numAxes(); @@ -2572,7 +2579,10 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { axis.computedValueRange = [axis.valueWindow[0], axis.valueWindow[1]]; } else if (axis.valueRange) { // This is a user-set value range for this axis. - axis.computedValueRange = [axis.valueRange[0], axis.valueRange[1]]; + axis.computedValueRange = [ + isNullUndefinedOrNaN(axis.valueRange[0]) ? axis.extremeRange[0] : axis.valueRange[0], + isNullUndefinedOrNaN(axis.valueRange[1]) ? axis.extremeRange[1] : axis.valueRange[1] + ]; } else { axis.computedValueRange = axis.extremeRange; }