The API for chart.js allows one to edit points of the datasets loaded into it, for example:
.update( ) Calling update() on
.update( )
Calling update() on
Not is necesary destroy the chart. Try with this
function removeData(chart) { let total = chart.data.labels.length; while (total >= 0) { chart.data.labels.pop(); chart.data.datasets[0].data.pop(); total--; } chart.update(); }