From 34ad56b341279a066dc8bad129501d8d254699c1 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Sat, 9 Feb 2013 14:14:09 -0500 Subject: [PATCH] Fix bug 329 which accumulates clipping rectangles on subsequent draws. --- dygraph-canvas.js | 7 +++++++ dygraph.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 0e1bc75..e531ece 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -57,6 +57,8 @@ var DygraphCanvasRenderer = function(dygraph, element, elementContext, layout) { this.height = this.element.height; this.width = this.element.width; + this.elementContext.save(); + // --- check whether everything is ok before we return if (!this.isIE && !(DygraphCanvasRenderer.isSupported(this.element))) throw "Canvas is not supported."; @@ -125,6 +127,11 @@ DygraphCanvasRenderer.prototype.clear = function() { context.clearRect(0, 0, this.width, this.height); }; +DygraphCanvasRenderer.prototype.onDoneDrawing = function() { + // balances the save called in the constructor. + this.elementContext.restore(); +} + /** * Checks whether the browser supports the <canvas> tag. * @private diff --git a/dygraph.js b/dygraph.js index a02d919..f198cff 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2200,6 +2200,8 @@ Dygraph.prototype.predraw_ = function() { // If the data or options have changed, then we'd better redraw. this.drawGraph_(); + this.plotter_.onDoneDrawing(); + // This is used to determine whether to do various animations. var end = new Date(); this.drawingTimeMs_ = (end - start); -- 2.7.4