I have the following onClick function inside my ChartJS instance. It works perfectly to access component variables.
onClick: () => {
console.log(this.test);
},
Now I need to get some informations about the chart.
For example:
Using this function bellow I can access event of click and array but I can't access component variable like in the first arrow function
chartClickEvent(event, array) {
const ENTRADA = 0, SAIDA = 1;
if (array[0]) {
let columnIndex = array[0]._index;
if (columnIndex == ENTRADA) {
console.log(this.test);
}
}
}
It's shows undefined when I try to print component variable
onClick: chartClickEvent,
How to access both? Data about chart and component variable
onClick: (event, array) => this.chartClickEvent(event, array)