Chartjs-Chartjs: How do you toggle the visibility of charts in Ionic 4

1👍

Add a function to remove any existing chart from the canvas:

destroyChart() {
 if(this.bars) {
    this.bars.destroy()
 }
}

Call this function right before any calls to new Chart

Also, maybe rename this.bars to this.currentChart

See https://www.chartjs.org/docs/latest/developers/api.html#destroy

Leave a comment