From 437c097971f7b20e593e256385bbc998c781e1d2 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Thu, 23 Sep 2010 17:27:51 -0400 Subject: [PATCH] Reorder unzoom operation with log of operation, which properly sets the valueRange for recording. Improve usability of zoom demo for testing. --- dygraph.js | 4 +++- tests/zoom.html | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/dygraph.js b/dygraph.js index 36986d8..f20e1e1 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1055,6 +1055,9 @@ Dygraph.prototype.doUnzoom_ = function() { } if (dirty) { + // Putting the drawing operation before the callback because it resets + // yAxisRange. + this.drawGraph_(this.rawData_); if (this.attr_("zoomCallback")) { var minDate = this.rawData_[0][0]; var maxDate = this.rawData_[this.rawData_.length - 1][0]; @@ -1062,7 +1065,6 @@ Dygraph.prototype.doUnzoom_ = function() { var maxValue = this.yAxisRange()[1]; this.attr_("zoomCallback")(minDate, maxDate, minValue, maxValue); } - this.drawGraph_(this.rawData_); } }; diff --git a/tests/zoom.html b/tests/zoom.html index c59284a..608ae6d 100644 --- a/tests/zoom.html +++ b/tests/zoom.html @@ -11,19 +11,26 @@ -

Click the buttons to change the zoom

+

Click the buttons to change the zoom level or just use the normal + click-and drag.

Window coordinates (in dates and values):

Zoom operations:

-   -   -   -   -   -   +   +   +   +   +   +
+   +   +   +   +
+  

@@ -43,7 +50,6 @@ var maxDate = g.xAxisRange()[1]; var minValue = g.yAxisRange()[0]; var maxValue = g.yAxisRange()[1]; - showDimensions(minDate, maxDate, minValue, maxValue); function showDimensions(minDate, maxDate, minValue, maxValue) { @@ -53,21 +59,16 @@ "valueRange : [" + minValue + " , "+ maxValue + "],"; } - function sizeGraph(i) { - switch(i) { - case 0: g.doUnzoom_(); - break; - case 1: g.doZoomYValues_(5, 3); - break; - case 2: g.doZoomYValues_(4, 0); - break; - case 3: g.doZoomYValues_(4, 2); - break; - case 4: g.doZoomYValues_(2, 0); - break; - case 5: g.doZoomYValues_(1, 0); - break; - } + function zoomGraphX(minDate, maxDate) { + g.doZoomXDates_(minDate, maxDate); + } + + function zoomGraphY(minValue, maxValue) { + g.doZoomYValues_(minValue, maxValue); + } + + function unzoomGraph() { + g.doUnzoom_(); } -- 2.7.4