[Vuejs]-Chart js name label not updating in vuejs

0👍

This is a common Vue reactivity problem. You need to make deep copy to make data reactive.

One solution is using JSON.parse(JSON.stringify())

addData: function addData() {
  this.dataset.push(this.dataentry);
  this.labels.push(this.datalabel);
  this.labels = JSON.parse(JSON.stringify(this.labels))
  this.dataset = JSON.parse(JSON.stringify(this.dataset))
  this.datalabel = 'bhumi';
  this.dataentry = '';
  this.roundentry = '';
  this.carbon = '';
  this.HRC = '';
  this.legend = legend;
}

Vue list rendering caveats

0👍

If you’re not using vue-chartjs I’d recommend it, it can handle the reactivity for you and is pretty full featured.

vue-chartjs calls out some reactivity trouble in it’s documentation Here

Leave a comment