Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auto_tests/tests/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

/**
Expand Down
14 changes: 14 additions & 0 deletions src/dygraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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_);
}
};

/**
Expand Down