Chartjs-Using a function in ng2 Charts

0👍

You should define the onHover callback function as follows:

onHover: () => this.changeFontColor(), 

The changeFontColor method would also have to be changed. Please note that I reassign lineChartOptions with a copy of itself to make Angular change detection work.

changeFontColor(): void {
  this.lineChartOptions.legend.labels.fontColor = "red";
  this.lineChartOptions = JSON.parse(JSON.stringify(this.lineChartOptions));
};

Please take a look at your amended StackBlitz.

Leave a comment