Merge branch 'master' of https://github.com/kberg/dygraphs
[dygraphs.git] / dygraph.js
index be1cecb..1b8d8c7 100644 (file)
@@ -2719,6 +2719,20 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
     seriesForAxis[idx].push(series);
   }
 
+  // If no series are defined or visible then fill in some reasonable defaults.
+  if (seriesForAxis.length == 0) {
+    var axis = this.axes_[0];
+    axis.computedValueRange = [0, 1];
+    var ret =
+      Dygraph.numericTicks(axis.computedValueRange[0],
+                           axis.computedValueRange[1],
+                           this,
+                           axis);
+    axis.ticks = ret.ticks;
+    this.numYDigits_ = ret.numDigits;
+    return;
+  }
+
   // Compute extreme values, a span and tick marks for each axis.
   for (var i = 0; i < this.axes_.length; i++) {
     var axis = this.axes_[i];
@@ -3327,6 +3341,11 @@ Dygraph.prototype.parseDataTable_ = function(data) {
           annotations.push(ann);
         }
       }
+
+      // Strip out infinities, which give dygraphs problems later on.
+      for (var j = 0; j < row.length; j++) {
+        if (!isFinite(row[j])) row[j] = null;
+      }
     } else {
       for (var j = 0; j < cols - 1; j++) {
         row.push([ data.getValue(i, 1 + 2 * j), data.getValue(i, 2 + 2 * j) ]);
@@ -3335,11 +3354,6 @@ Dygraph.prototype.parseDataTable_ = function(data) {
     if (ret.length > 0 && row[0] < ret[ret.length - 1][0]) {
       outOfOrder = true;
     }
-
-    // Strip out infinities, which give dygraphs problems later on.
-    for (var j = 0; j < row.length; j++) {
-      if (!isFinite(row[j])) row[j] = null;
-    }
     ret.push(row);
   }