Skip to content

Commit

Permalink
fix chart would not be destoried when that is unused
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Sep 3, 2017
1 parent 213b53f commit 031a8da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/scripts/directives/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
setOptions(value);
}
}, true);

scope.$on('$destroy', function() {
if (chart && !chart.isDisposed()) {
chart.dispose();
}
});
}
};
}]).directive('ngPopChart', ['$window', 'chartTheme', function ($window, chartTheme) {
Expand Down Expand Up @@ -79,7 +85,7 @@

chart = echarts.init(wrapper[0], chartTheme.get(options.ngTheme));
}).on('hide.bs.popover', function () {
if (chart && chart.isDisposed()) {
if (chart && !chart.isDisposed()) {
chart.dispose();
}
}).on('hidden.bs.popover', function () {
Expand Down

0 comments on commit 031a8da

Please sign in to comment.