Destroy chart on redraw

This commit is contained in:
Torjus Håkestad 2021-04-10 17:48:33 +02:00
parent ef92e31195
commit a51fb5d80b

View File

@ -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,