From f8cfec734263f9eea52dd0a5c01bdf642ebc12b8 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Thu, 3 Dec 2009 10:10:28 -0800 Subject: [PATCH] changes to make grid_dot test work in IE8 --- dygraph-canvas.js | 11 ----------- dygraph.js | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index d1594f3..58e6917 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -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; diff --git a/dygraph.js b/dygraph.js index f940cad..c5ee9d1 100644 --- a/dygraph.js +++ b/dygraph.js @@ -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. -- 2.7.4