Skip to content

Commit 8b4dacf

Browse files
committed
Stop watching when chart is destroyed (#4)
1 parent d22f5a0 commit 8b4dacf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/plugin.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import Chart from 'chart.js';
4949
var canvas = instance.chart.canvas;
5050

5151
// http://stackoverflow.com/a/21696585
52-
if (canvas.offsetParent === null) {
52+
if (!canvas || canvas.offsetParent === null) {
5353
return false;
5454
}
5555

@@ -199,6 +199,10 @@ import Chart from 'chart.js';
199199
// as interacting with the legend label, or direct calls to update()
200200
return false;
201201
}
202+
},
203+
204+
destroy: function(chart) {
205+
unwatch(chart);
202206
}
203207
});
204208

0 commit comments

Comments
 (0)