Destroy chart on redraw
This commit is contained in:
parent
ef92e31195
commit
a51fb5d80b
@ -69,6 +69,8 @@ export default class StatsPie extends Vue {
|
||||
|
||||
stats: StatResult[];
|
||||
|
||||
chart?: Chart;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.stats = [];
|
||||
@ -152,7 +154,10 @@ export default class StatsPie extends Vue {
|
||||
const headers = sortedStats.map((s) => s.name);
|
||||
const colors = sortedStats.map(() => randomColor());
|
||||
|
||||
const chart = new Chart(ctx, {
|
||||
if (this.chart) {
|
||||
this.chart.destroy();
|
||||
}
|
||||
this.chart = new Chart(ctx, {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: headers,
|
||||
|
Loading…
Reference in New Issue
Block a user