From a51fb5d80b817d51f2e48e354a7ed0a093ff0246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sat, 10 Apr 2021 17:48:33 +0200 Subject: [PATCH] Destroy chart on redraw --- web/frontend/src/components/StatsPie.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/frontend/src/components/StatsPie.vue b/web/frontend/src/components/StatsPie.vue index 1eb796c..c3e7e7e 100644 --- a/web/frontend/src/components/StatsPie.vue +++ b/web/frontend/src/components/StatsPie.vue @@ -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,