From 74f09e22ec074b0a1c2c8fc1e5f88e296121f7a6 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Fri, 8 Oct 2010 10:03:57 -0400 Subject: [PATCH] y-axis scaling is automatic until a) user zooms in on the y-axis or b) a value range is defined on construction. --- dygraph.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dygraph.js b/dygraph.js index 2e7fa0f..f70bfa9 100644 --- a/dygraph.js +++ b/dygraph.js @@ -810,9 +810,14 @@ Dygraph.prototype.createDragInterface_ = function() { var maxDate = minDate + dateRange; self.dateWindow_ = [minDate, maxDate]; - var maxValue = draggingValue + (dragEndY / self.height_) * valueRange; - var minValue = maxValue - valueRange; - self.valueWindow_ = [ minValue, maxValue ]; + // if a y-axis as been defined then the y-axis scale is maintained. + // otherwise don't set a value window, thereby forcing automatic y-axis + // scaling. + if (self.valueWindow_) { + var maxValue = draggingValue + (dragEndY / self.height_) * valueRange; + var minValue = maxValue - valueRange; + self.valueWindow_ = [ minValue, maxValue ]; + } self.drawGraph_(self.rawData_); } }); -- 2.7.4