Chart with ID '0' must be destroyed before the canvas with ID '' can be reused
Ceritanya lagi bikin chart dinamis pake ChartJS.
Jadi ane pasang element select option buat ngefilter periode data yang direquest melalui ajax.
Kaya gini lah bentukannya.
masalahnya pas ane milih periode lain, munculah error:
Error fetching chart data for daily transactions: Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas with ID '' can be reused
Kebetulan ane pake alpine js, jadi agak tricky juga nyari solusinya.
Dan ternyata solusinya hanya perlu didestroy aja chart yang sebelumnya terpakai.
contoh:
let chart = null;
if (chart) {
chart.destroy()
}
chart = new Chart(...........,
Posting Komentar untuk "Chart with ID '0' must be destroyed before the canvas with ID '' can be reused"