From: Robert Konigsberg Date: Fri, 13 May 2011 15:37:40 +0000 (-0400) Subject: When pan is the default behavior, clearSelection can't be called on X-Git-Tag: v1.0.0~463^2~1^2~11 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=fc4e84fafa99a27372b55bbd5f28f8af8429f3d0;p=dygraphs.git When pan is the default behavior, clearSelection can't be called on redraw. --- diff --git a/auto_tests/tests/interaction_model.js b/auto_tests/tests/interaction_model.js index 2698b5f..6249731 100644 --- a/auto_tests/tests/interaction_model.js +++ b/auto_tests/tests/interaction_model.js @@ -123,7 +123,6 @@ InteractionModelTestCase.prototype.testClickCallbackIsCalledOnCustomPan = functi DygraphOps.dispatchMouseMove_Point(g, 10, 10); DygraphOps.dispatchMouseUp_Point(g, 10, 10); - // THIS STILL FAILS. It's clicked, but x is undefined. - // assertEquals(20, clicked); + assertEquals(20, clicked); }; diff --git a/dygraph.js b/dygraph.js index 61e8e49..c10ef05 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1227,7 +1227,7 @@ Dygraph.Interaction.movePan = function(event, g, context) { } } - g.drawGraph_(); + g.drawGraph_(false); }; /** @@ -2674,9 +2674,19 @@ Dygraph.prototype.predraw_ = function() { * Update the graph with new data. This method is called when the viewing area * has changed. If the underlying data or options have changed, predraw_ will * be called before drawGraph_ is called. + * + * clearSelection, when undefined or true, causes this.clearSelection to be + * called at the end of the draw operation. This should rarely be defined, + * and never true (that is it should be undefined most of the time, and + * rarely false.) + * * @private */ -Dygraph.prototype.drawGraph_ = function() { +Dygraph.prototype.drawGraph_ = function(clearSelection) { + if (typeof clearSelection === 'undefined') { + clearSelection = true; + } + var data = this.rawData_; // This is used to set the second parameter to drawCallback, below. @@ -2819,13 +2829,15 @@ Dygraph.prototype.drawGraph_ = function() { // Generate a static legend before any particular point is selected. this.setLegendHTML_(); } else { - if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) { - // We should select the point nearest the page x/y here, but it's easier - // to just clear the selection. This prevents erroneous hover dots from - // being displayed. - this.clearSelection(); - } else { - this.clearSelection(); + if (clearSelection) { + if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) { + // We should select the point nearest the page x/y here, but it's easier + // to just clear the selection. This prevents erroneous hover dots from + // being displayed. + this.clearSelection(); + } else { + this.clearSelection(); + } } }