From aa0b189f8cb22d64ce65cc9b205c90f6e4fd1257 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Wed, 8 Feb 2017 13:20:36 -0500 Subject: [PATCH] Make dblclick event cancelable. (#840) Add demo of how to restore the dygraphs 1.x zoom out behavior. --- src/dygraph-interaction-model.js | 3 +- src/dygraph.js | 1 + tests/old-yrange-behavior.html | 64 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/old-yrange-behavior.html 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.

+ +
+
+ + + + -- 2.7.4