0👍
Try to use bind()
to bind context to a function.
public pieChartOptions: ChartOptions = {
responsive: true,
legend: {
position: 'left',
onClick: this.handleClick.bind(this, event, item)
},
title: {text: '', display: true}
};
handleClick(ev, item): void {
this.legendClick.emit(item.index)
}
- Chartjs-How to use chartJS to show breakdown of selected data
- Chartjs-Fill color to pointer in Chartjs
Source:stackexchange.com