Skip to content

Commit

Permalink
Merge pull request #855 from nnnick/fix/reset-canvas
Browse files Browse the repository at this point in the history
Restore original canvas context when destroying
  • Loading branch information
etimberg committed Jan 7, 2015
2 parents 74c9ef5 + 85f3755 commit 854cebc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Chart.Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit 854cebc

Please sign in to comment.