X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=941badb9a01edcf41444d34330d35825a1808470;hb=de9a8181064aa767e1c70c31a0027a0324cc33c6;hp=3a5957faaee02a38df62a19cc8e7215de6601d3e;hpb=90ccd1c3393245e04a64a849e4c4e9f3e2d73c05;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 3a5957f..941badb 100644 --- a/dygraph.js +++ b/dygraph.js @@ -956,19 +956,20 @@ Dygraph.prototype.createInterface_ = function() { var dygraph = this; - // Don't recreate and register the handlers on subsequent calls. - // This happens when the graph is resized. - if (!this.mouseMoveHandler_) { - this.mouseMoveHandler_ = function(e) { - dygraph.mouseMove_(e); - }; - this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_); + this.mouseMoveHandler_ = function(e) { + dygraph.mouseMove_(e); + }; - this.mouseOutHandler_ = function(e) { - dygraph.mouseOut_(e); - }; - this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_); + this.mouseOutHandler_ = function(e) { + dygraph.mouseOut_(e); + }; + + this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_); + this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_); + // Don't recreate and register the resize handler on subsequent calls. + // This happens when the graph is resized. + if (!this.resizeHandler_) { this.resizeHandler_ = function(e) { dygraph.resize(); }; @@ -1280,6 +1281,12 @@ Dygraph.prototype.createDragInterface_ = function() { bindHandler(interactionModel[eventName])); } + // unregister the handler on subsequent calls. + // 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. this.mouseUpHandler_ = function(event) { @@ -2496,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(); @@ -2569,8 +2580,8 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { } else if (axis.valueRange) { // This is a user-set value range for this axis. axis.computedValueRange = [ - !isNaN(axis.valueRange[0]) && axis.valueRange[0] !== null && axis.valueRange[0] !== undefined ? axis.valueRange[0] : axis.extremeRange[0], - !isNaN(axis.valueRange[1]) && axis.valueRange[1] !== null && axis.valueRange[1] !== undefined ? axis.valueRange[1] : axis.extremeRange[1] + 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;