1๐
โ
I think the variable chart
is unknown in the scope of main.js
. Therefore, you would need to provide the chart
variable to show_info
like so:
// main.js
function show_info(my_object) {
alert(my_object.data.labels[activeEls[0].index]);
}
// other file
onClick: (evt, activeEls, chart) => {
show_info(chart);
},
Source:stackexchange.com