0👍
If you write, onClick: () => {}
, this
will be the component/class when writing an arrow function.
If you write, onClick: function() {}
, this
will be the chart object.
If you want access to both the chart object and component/class, I would use the utility of thisAsThat
linked below and explained as well.
TypeScript: How to use both fat arrow and this?
For onClick:
you can use the utility of thisAsThat
that’s present in the answer where this
will be the class/component and that
will be the chart object.
I would also consider using ng2-charts
which is a wrapper around chart.js
where it has a (chartClicked)
event.
- Chartjs-Displaying the first value of the array in datasets.label Chartjs
- Chartjs-Chart.js display even intervals between two dates and adding label to y axes
Source:stackexchange.com