[Vuejs]-Vue-ChartJS datasets push not updating chart

0👍

It might be Vue reactivity problem. You need to update references to this.transactions to make Vue reactive

updateChart(period) {
  console.log('Chart updated for period: ' + period);
  this.transactions.datasets.push({
    label: 'Users',
    data: [123, 19, 3, 5, 2, 3, 20, 33, 23, 12, 33, 10],
    backgroundColor: 'rgba(66, 165, 245, 0.5)',
    borderColor: '#2196F3',
    borderWidth: 1
  });
  this.transactions = JSON.parse(JSON.stringify(this.transactions))
}

Leave a comment