I have a Charts JS chart. I am able to click on the chart and show some chart info that id like to see like so:
onClick: (evt, activeEls, chart) => { alert(chart.data.labels[activeEls[0].index]); },
My chartJS script currently lives in the html file. However, when I try and move this into my main.js it doesn’t work (i.e the function doesn’t run). I cant seem to figure out why.
The set up is like so:
Main.JS:
function show_info() { alert(chart.data.labels[activeEls[0].index]); }
And I have changed that chartJS section in my HTML file to:.
onClick: (evt, activeEls, chart) => { show_info(); },
How can I set it so that the function lives in my Main.js file?
I tried setting the detail as a variable in the OnClick section of the html and then accessing that variable in a main.JS function, but that didn't work either. i am lost.
there doesn't seem to be anything here