score:0

the problem is that you invoke update() on the chartdata object but not on the chart instance. the chartdata object does not have an update() function.

how to get a reference to the chart.js instance is explained here.

below code fragments illustrate what needs to be changed in your code to solve your problem.

constructor() {
  ... 
  this.chartreference = react.createref(); 
}

componentdidmount() {
  this.chart = this.chartreference.current.chartinstance;
  ...
}

adddata(chart) {
   ...
   this.chart.update(); // instead of chart.update();
}

removedata(chart) {
   ...
   this.chart.update(); // instead of chart.update();
}

render() {
  return (
    ...
    <bar
      ref={this.chartreference}
      ...
    />
    ...
  );
}

Related Query

More Query from same tag