diff --git a/auto_tests/tests/resize.js b/auto_tests/tests/resize.js index 6230ffb94..d31ceb0e5 100644 --- a/auto_tests/tests/resize.js +++ b/auto_tests/tests/resize.js @@ -43,14 +43,14 @@ it('testResizeMaintainsMouseOperations', function() { var g = new Dygraph(graph, data, {highlightCallback: callback}); strum(g, 300, 640); - assert.equal(6, callbackCount); + assert.equal(7, callbackCount); graph.style.width = "500px"; g.resize(); callbackCount = 0; strum(g, 300, 500); - assert.equal(6, callbackCount); + assert.equal(7, callbackCount); }); /** diff --git a/src/dygraph.js b/src/dygraph.js index ba4473925..94550c2ab 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -212,6 +212,8 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { this.eventListeners_ = {}; this.attributes_ = new DygraphOptions(this); + this.lastMouseMoveEvent_ = null; + this.currentZoomRectArgs_ = null; // Create the containing DIV and other interactive elements this.createInterface_(); @@ -1211,6 +1213,7 @@ Dygraph.prototype.drawZoomRect_ = function(direction, startX, endX, startY, endY, prevDirection, prevEndX, prevEndY) { var ctx = this.canvas_ctx_; + this.currentZoomRectArgs_ = arguments; // Clean up from the previous rect if necessary if (prevDirection == utils.HORIZONTAL) { @@ -1591,6 +1594,8 @@ Dygraph.prototype.findStackedPoint = function(domX, domY) { * @private */ Dygraph.prototype.mouseMove_ = function(event) { + this.lastMouseMoveEvent_ = event; + // This prevents JS errors when mousing over the canvas before data loads. var points = this.layout_.points; if (points === undefined || points === null) return; @@ -2350,6 +2355,15 @@ Dygraph.prototype.renderGraph_ = function(is_initial_draw) { fn(this); } } + + if(this.lastMouseMoveEvent_ !== null) + { + this.mouseMove_(this.lastMouseMoveEvent_); + } + if(this.currentZoomRectArgs_ !== null) + { + this.drawZoomRect_.apply(this, this.currentZoomRectArgs_); + } }; /**