Chart.js has an error: Chart.controller(instance) registers any new chart in the global Chart.instances[] property and removes it from this property on .destroy() .
But when creating a chart, Chart.js also writes the ._meta property to the data set variable:
var meta = dataset._meta[me.id]; if (!meta) { meta = dataset._meta[me.id] = { type: null, data: [], dataset: null, controller: null, hidden: null, // See isDatasetVisible() comment xAxisID: null, yAxisID: null };
and does not remove this property on destroy() .
If you use the old dataset object without deleting the ._meta property , Chart.js will add the new dataset to ._meta without deleting the previous data. Thus, each time you re-initialize the chart, your dataset object accumulates all previous data.
To avoid this, destroy the dataset object after calling Chart.destroy() .
Andrew Hudik Aug 12 '16 at 13:49 on 2016-08-12 13:49
source share