From: Dan Vanderkam Date: Thu, 3 Dec 2009 18:10:28 +0000 (-0800) Subject: changes to make grid_dot test work in IE8 X-Git-Tag: v1.0.0~820 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=f8cfec734263f9eea52dd0a5c01bdf642ebc12b8;p=dygraphs.git changes to make grid_dot test work in IE8 --- 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.