Chartjs-Generating different chart results on fly causes flickering

0👍

Instead of creating a new chart or re-assigning datasets, you have to mutate the existing datasets to get them to animate nicely.

e.g.

const chart = new Chart(ctx, { ... });
//chart.datasets = [/* new datasets */] // bad! won't animate
chart.datasets[0].data = [/* new data */] // good!
chart.update(); 

Leave a comment