From: Nick Downie Date: Tue, 6 Jan 2015 23:44:51 +0000 (+0000) Subject: Restore original canvas context when destroying X-Git-Tag: v1.0.1~3^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F855%2Fhead;p=thirdparty%2FChart.js.git Restore original canvas context when destroying --- 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){