i
authorclocksmith <antrob@google.com>
Sat, 23 Feb 2013 00:19:26 +0000 (19:19 -0500)
committerclocksmith <antrob@google.com>
Sat, 23 Feb 2013 00:19:26 +0000 (19:19 -0500)
dygraph.js

index 4ba9a7c..c1a9bce 100644 (file)
@@ -2594,9 +2594,30 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
     var includeZero = this.attributes_.getForAxis("includeZero", i);
     series = this.attributes_.seriesForAxis(i);
 
+    // Add some padding. This supports two Y padding operation modes:
+    //
+    // - backwards compatible (yRangePad not set):
+    //   10% padding for automatic Y ranges, but not for user-supplied
+    //   ranges, and move a close-to-zero edge to zero except if
+    //   avoidMinZero is set, since drawing at the edge results in
+    //   invisible lines. Unfortunately lines drawn at the edge of a
+    //   user-supplied range will still be invisible. If logscale is
+    //   set, add a variable amount of padding at the top but
+    //   none at the bottom.
+    //
+    // - new-style (yRangePad set by the user):
+    //   always add the specified Y padding.
+    //
+    ypadCompat = true;
+    ypad = 0.1; // add 10%
+    if (this.attr_('yRangePad') !== null) {
+      ypadCompat = false;
+      // Convert pixel padding to ratio
+      ypad = this.attr_('yRangePad') / this.plotter_.area.h;
+    }
+
     if (series.length === 0) {
       // If no series are defined or visible then use a reasonable default
-      ypadCompat = true;
       axis.extremeRange = [0, 1];
     } else {
       // Calculate the extremes of extremes.
@@ -2641,28 +2662,6 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
         }
       }
 
-      // Add some padding. This supports two Y padding operation modes:
-      //
-      // - backwards compatible (yRangePad not set):
-      //   10% padding for automatic Y ranges, but not for user-supplied
-      //   ranges, and move a close-to-zero edge to zero except if
-      //   avoidMinZero is set, since drawing at the edge results in
-      //   invisible lines. Unfortunately lines drawn at the edge of a
-      //   user-supplied range will still be invisible. If logscale is
-      //   set, add a variable amount of padding at the top but
-      //   none at the bottom.
-      //
-      // - new-style (yRangePad set by the user):
-      //   always add the specified Y padding.
-      //
-      ypadCompat = true;
-      ypad = 0.1; // add 10%
-      if (this.attr_('yRangePad') !== null) {
-        ypadCompat = false;
-        // Convert pixel padding to ratio
-        ypad = this.attr_('yRangePad') / this.plotter_.area.h;
-      }
-
       var maxAxisY, minAxisY;
       if (logscale) {
         if (ypadCompat) {