changes to make grid_dot test work in IE8
authorDan Vanderkam <danvk@google.com>
Thu, 3 Dec 2009 18:10:28 +0000 (10:10 -0800)
committerDan Vanderkam <danvk@google.com>
Thu, 3 Dec 2009 18:10:28 +0000 (10:10 -0800)
dygraph-canvas.js
dygraph.js

index d1594f3..58e6917 100644 (file)
@@ -185,17 +185,6 @@ DygraphCanvasRenderer = function(dygraph, element, layout, options) {
   this.element = element;
   this.container = this.element.parentNode;
 
-  // Stuff relating to Canvas on IE support    
-  this.isIE = (/MSIE/.test(navigator.userAgent) && !window.opera);
-
-  if (this.isIE && !isNil(G_vmlCanvasManager)) {
-      this.IEDelay = 0.5;
-      this.maxTries = 5;
-      this.renderDelay = null;
-      this.clearDelay = null;
-      this.element = G_vmlCanvasManager.initElement(this.element);
-  }
-
   this.height = this.element.height;
   this.width = this.element.width;
 
index f940cad..c5ee9d1 100644 (file)
@@ -293,10 +293,13 @@ Dygraph.prototype.createInterface_ = function() {
   enclosing.appendChild(this.graphDiv);
 
   // Create the canvas for interactive parts of the chart.
-  this.canvas_ = document.createElement("canvas");
+  // this.canvas_ = document.createElement("canvas");
+  this.canvas_ = Dygraph.createCanvas();
   this.canvas_.style.position = "absolute";
   this.canvas_.width = this.width_;
   this.canvas_.height = this.height_;
+  this.canvas_.style.width = this.width_ + "px";    // for IE
+  this.canvas_.style.height = this.height_ + "px";  // for IE
   this.graphDiv.appendChild(this.canvas_);
 
   // ... and for static parts of the chart.
@@ -319,12 +322,15 @@ Dygraph.prototype.createInterface_ = function() {
  * @private
  */
 Dygraph.prototype.createPlotKitCanvas_ = function(canvas) {
-  var h = document.createElement("canvas");
+  // var h = document.createElement("canvas");
+  var h = Dygraph.createCanvas();
   h.style.position = "absolute";
   h.style.top = canvas.style.top;
   h.style.left = canvas.style.left;
   h.width = this.width_;
   h.height = this.height_;
+  h.style.width = this.width_ + "px";    // for IE
+  h.style.height = this.height_ + "px";  // for IE
   this.graphDiv.appendChild(h);
   return h;
 };
@@ -1714,6 +1720,21 @@ Dygraph.prototype.adjustRoll = function(length) {
   this.drawGraph_(this.rawData_);
 };
 
+/**
+ * Create a new canvas element. This is more complex than a simple
+ * document.createElement("canvas") because of IE and excanvas.
+ */
+Dygraph.createCanvas = function() {
+  var canvas = document.createElement("canvas");
+
+  isIE = (/MSIE/.test(navigator.userAgent) && !window.opera);
+  if (isIE) {
+    canvas = G_vmlCanvasManager.initElement(canvas);
+  }
+
+  return canvas;
+};
+
 
 /**
  * A wrapper around Dygraph that implements the gviz API.