+ var yRange = this.yAxisRange();
+ this.attr_("zoomCallback")(minDate, maxDate, yRange[0], yRange[1]);
+ }
+};
+
+/**
+ * Zoom to something containing [lowY, highY]. These are pixel coordinates in
+ * the canvas. The exact zoom window may be slightly larger if there are no
+ * data points near lowY or highY. Don't confuse this function with
+ * doZoomYValues, which accepts parameters that match the raw data. This
+ * function redraws the graph.
+ *
+ * @param {Number} lowY The topmost pixel value that should be visible.
+ * @param {Number} highY The lowest pixel value that should be visible.
+ * @private
+ */
+Dygraph.prototype.doZoomY_ = function(lowY, highY) {
+ // Find the highest and lowest values in pixel range.
+ var r = this.toDataCoords(null, lowY);
+ var minValue = r[1];
+ r = this.toDataCoords(null, highY);
+ var maxValue = r[1];
+
+ this.doZoomYValues_(minValue, maxValue);
+};
+
+/**
+ * Zoom to something containing [minValue, maxValue] values. Don't confuse this
+ * method with doZoomY which accepts pixel coordinates. This function redraws
+ * the graph.
+ *
+ * @param {Number} minValue The minimum Value that should be visible.
+ * @param {Number} maxValue The maximum value that should be visible.
+ * @private
+ */
+Dygraph.prototype.doZoomYValues_ = function(minValue, maxValue) {
+ this.valueWindow_ = [maxValue, minValue];
+ this.drawGraph_(this.rawData_);
+ if (this.attr_("zoomCallback")) {
+ var xRange = this.xAxisRange();
+ this.attr_("zoomCallback")(xRange[0], xRange[1], minValue, maxValue);
+ }
+};
+
+/**
+ * Reset the zoom to the original view coordinates. This is the same as
+ * double-clicking on the graph.
+ *
+ * @private
+ */
+Dygraph.prototype.doUnzoom_ = function() {
+ var dirty = null;
+ if (this.dateWindow_ != null) {
+ dirty = 1;
+ this.dateWindow_ = null;
+ }
+ if (this.valueWindow_ != null) {
+ dirty = 1;
+ this.valueWindow_ = this.valueRange_;
+ }
+
+ if (dirty) {
+ if (this.attr_("zoomCallback")) {
+ var minDate = this.rawData_[0][0];
+ var maxDate = this.rawData_[this.rawData_.length - 1][0];
+ var minValue = this.xAxisRange()[0];
+ var maxValue = this.xAxisRange()[1];
+ this.attr_("zoomCallback")(minDate, maxDate, minValue, maxValue);
+ }
+ this.drawGraph_(this.rawData_);