From: Dan Vanderkam Date: Sun, 5 Feb 2017 15:47:41 +0000 (-0500) Subject: Make dblclick event cancelable. X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=64e98f172c606dd4f9622ae6fd48094bf490d217;p=dygraphs.git Make dblclick event cancelable. Add demo of how to restore the dygraphs 1.x zoom out behavior. --- diff --git a/src/dygraph-interaction-model.js b/src/dygraph-interaction-model.js index 349fd3e..494b638 100644 --- a/src/dygraph-interaction-model.js +++ b/src/dygraph-interaction-model.js @@ -706,7 +706,8 @@ DygraphInteraction.defaultModel = { // Give plugins a chance to grab this event. var e = { canvasx: context.dragEndX, - canvasy: context.dragEndY + canvasy: context.dragEndY, + cancelable: true, }; if (g.cascadeEvents_('dblclick', e)) { return; diff --git a/src/dygraph.js b/src/dygraph.js index d503669..61e96f7 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -1350,6 +1350,7 @@ Dygraph.prototype.resetZoom = function() { const zoomCallback = this.getFunctionOption('zoomCallback'); // TODO(danvk): merge this block w/ the code below. + // TODO(danvk): factor out a generic, public zoomTo method. if (!animatedZooms) { this.dateWindow_ = null; this.axes_.forEach(axis => { diff --git a/tests/old-yrange-behavior.html b/tests/old-yrange-behavior.html new file mode 100644 index 0000000..d70ff1a --- /dev/null +++ b/tests/old-yrange-behavior.html @@ -0,0 +1,64 @@ + + + + + Old y-axis range behavior + + + + + +

Old y-axis range behavior

+

In dygraphs 1.x, if you set a valueRange for the y-axis, zoomed in and then double-clicked to zoom out, then the chart would zoom out to the valueRange that you specified.

+

Starting with dygraphs 2, double-clicking will zoom out to the full range of the chart's data. This makes the x- and y-axes behave identically.

+

This demo shows you how to get the old behavior in dygraphs 2 using a plugin. View source to see how.

+ +
+
+ + + +