Reputation: 2170
I'm using this tutorial to draw charts using chart.js in Wix Valo
For create the chart I'm using
async function chart(data_chart){
var chart = new ChartJSAPI($w('#customElement1'));
chart.customization = data_chart.customization
chart.data = data_chart.data
}
And it working well
But when I call again to chart function
I got this error
chart.js:5552 Uncaught Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas with ID 'myChart' can be reused.
I tried to implement this:
But there is no function
chart.destroy();
How to destroy it?
Upvotes: 1
Views: 85
Reputation: 31371
After you have created the chart you don't have to re-create it. You can just update the data of the chart by setting chart.data = newData
and chart.customization = newCustomization
and then it should update automatically.
Upvotes: 2