Chartjs-Updating Chartjs Line chart from database

0👍

A more straight forward solution (to me at least):

In your draw_chart method (or whatever you’re calling to draw the chart):

if (typeof chart != 'undefined')
    chart.destroy();

Destroy the existing chart if there is one.

From there, just add your data sets, and draw it.

This solution works well in both 1.x and 2.0.

Leave a comment