frappe / charts

Simple, responsive, modern SVG Charts with zero dependencies
https://frappe.io/charts
MIT License
14.9k stars 716 forks source link

Question: How can I trap a click event of a legend and get its details? #383

Open Mashiane opened 2 years ago

Mashiane commented 2 years ago

Hi there

I'd like to find out if its possible for one to trap a click event on legends, for example, clicking a Pie slice, getting the slice details selected as I would like to perform other actions depending on what is clicked.

Thank you so much!

scmmishra commented 2 years ago

The legend has a class legend-dataset-label and legend-dataset-value, the best you can do right now is to add event listeners to those once the chart is rendered

casesolved-co-uk commented 3 months ago

Is this still the best way to capture click events @uhrjun ? Just in vanilla JS in ERPNext, I don't really want to start using react.

uhrjun commented 3 months ago

Indeed, just capturing click events is the easiest way. Is there any problem with it right now? Does it break?