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[];
|
stats: StatResult[];
|
||||||
|
|
||||||
|
chart?: Chart;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.stats = [];
|
this.stats = [];
|
||||||
@ -152,7 +154,10 @@ export default class StatsPie extends Vue {
|
|||||||
const headers = sortedStats.map((s) => s.name);
|
const headers = sortedStats.map((s) => s.name);
|
||||||
const colors = sortedStats.map(() => randomColor());
|
const colors = sortedStats.map(() => randomColor());
|
||||||
|
|
||||||
const chart = new Chart(ctx, {
|
if (this.chart) {
|
||||||
|
this.chart.destroy();
|
||||||
|
}
|
||||||
|
this.chart = new Chart(ctx, {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: headers,
|
labels: headers,
|
||||||
|
Loading…
Reference in New Issue
Block a user