Skip to content

Commit

Permalink
Stop watching when chart is destroyed (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrunel committed Apr 27, 2017
1 parent d22f5a0 commit 8b4dacf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import Chart from 'chart.js';
var canvas = instance.chart.canvas;

// http://stackoverflow.com/a/21696585
if (canvas.offsetParent === null) {
if (!canvas || canvas.offsetParent === null) {
return false;
}

Expand Down Expand Up @@ -199,6 +199,10 @@ import Chart from 'chart.js';
// as interacting with the legend label, or direct calls to update()
return false;
}
},

destroy: function(chart) {
unwatch(chart);
}
});

Expand Down

0 comments on commit 8b4dacf

Please sign in to comment.