From: Robert Konigsberg Date: Fri, 8 Oct 2010 14:03:57 +0000 (-0400) Subject: y-axis scaling is automatic until a) user zooms in on the y-axis or b) a value range... X-Git-Tag: v1.0.0~613^2~12 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=74f09e22ec074b0a1c2c8fc1e5f88e296121f7a6;p=dygraphs.git y-axis scaling is automatic until a) user zooms in on the y-axis or b) a value range is defined on construction. --- 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_); } });