Chartjs-Colors are not updated when updating chart

0πŸ‘

βœ…

In your code, data is actually a dataset and must be defined as an object but not as an array. This problem can be solved by changing var data = []; to var data = {};.

function addBarData(chart, d) {
  var data = {};
  ...
}

function addPieData(chart, d) {
  var data = {};
  ...
}

Please have a look at your amended JSFiddle.

Leave a comment