From: Robert Konigsberg Date: Thu, 23 Sep 2010 21:27:51 +0000 (-0400) Subject: Reorder unzoom operation with log of operation, which properly sets the valueRange... X-Git-Tag: v1.0.0~613^2~22 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=437c097971f7b20e593e256385bbc998c781e1d2;p=dygraphs.git Reorder unzoom operation with log of operation, which properly sets the valueRange for recording. Improve usability of zoom demo for testing. --- 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_(); }