From 85f3755f9abd6a1b5224f61cb4e209739f850eed Mon Sep 17 00:00:00 2001 From: Nick Downie Date: Tue, 6 Jan 2015 23:44:51 +0000 Subject: [PATCH] Restore original canvas context when destroying --- src/Chart.Core.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 36a60841a..b71903e51 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -868,6 +868,21 @@ destroy : function(){ this.clear(); unbindEvents(this, this.events); + var canvas = this.chart.canvas; + + // Reset canvas height/width attributes starts a fresh with the canvas context + canvas.width = this.chart.width; + canvas.height = this.chart.height; + + // < IE9 doesn't support removeProperty + if (canvas.style.removeProperty) { + canvas.style.removeProperty('width'); + canvas.style.removeProperty('height'); + } else { + canvas.style.removeAttribute('width'); + canvas.style.removeAttribute('height'); + } + delete Chart.instances[this.id]; }, showTooltip : function(ChartElements, forceRedraw){ -- 2.47.2