Update chart data in angular2-chartjs

👍:0

You have to manually refresh as follows,

declare a variable _chart as follows,

@ViewChild(BaseChartDirective) private _chart;

you can refresh by using the following function,

 forceChartRefresh() {
    setTimeout(() => {
      this._chart.refresh();
    }, 10);
  }

and call after updating your data,

 this.forceChartRefresh();

👍:-1

@ViewChild(“loginChart”) bar: ChartComponent;

some_method(){

/*
your changes…
tus cambios

at the end put the following
al final poner lo siguiente
*/
this.bar.ngOnInit(); //it should work deberia funcionar

}

Leave a comment