Missing consistent use of getYRanges(). Fixed zoom.html to use yRanges in API.
[dygraphs.git] / dygraph.js
index 5cfe2f4..0dba534 100644 (file)
@@ -166,6 +166,16 @@ Dygraph.prototype.__old_init__ = function(div, file, labels, attrs) {
  * @private
  */
 Dygraph.prototype.__init__ = function(div, file, attrs) {
+  // Hack for IE: if we're using excanvas and the document hasn't finished
+  // loading yet (and hence may not have initialized whatever it needs to
+  // initialize), then keep calling this routine periodically until it has.
+  if (/MSIE/.test(navigator.userAgent) && !window.opera &&
+      typeof(G_vmlCanvasManager) != 'undefined' &&
+      document.readyState != 'complete') {
+    var self = this;
+    setTimeout(function() { self.__init__(div, file, attrs) }, 100);
+  }
+
   // Support two-argument constructor
   if (attrs == null) { attrs = {}; }
 
@@ -1077,7 +1087,7 @@ Dygraph.prototype.doZoomXDates_ = function(minDate, maxDate) {
   this.drawGraph_();
   if (this.attr_("zoomCallback")) {
     var yRange = this.yAxisRange();
-    this.attr_("zoomCallback")(minDate, maxDate, yRange[0], yRange[1]);
+    this.attr_("zoomCallback")(minDate, maxDate, this.yAxisRanges());
   }
 };
 
@@ -2403,7 +2413,8 @@ Dygraph.prototype.parseCSV_ = function(data) {
   // Parse the x as a float or return null if it's not a number.
   var parseFloatOrNull = function(x) {
     var val = parseFloat(x);
-    return isNaN(val) ? null : val;
+    // isFinite() returns false for NaN and +/-Infinity.
+    return isFinite(val) ? val : null;
   };
 
   var xParser;
@@ -2635,6 +2646,11 @@ 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);
   }