add click (and other) event handle to labels
Offbeatmammal opened this issue · 2 comments
Feature Proposal
I know there are some hacky ways to trap a generalised onClick for the canvas and work out if the click happened in the area of a label, but I've not found a clean solution (that works reliably for both horizontal and vertical axes) though happy to explore any recommendations.
our two use-cases are:
- some charts have quite long labels so we want to be able to implement either a tooltip or an inplace scroll when hovering over them
- one chart does a drill-down on the selected row when the user clicks on the label (got this working for X axis using some code off stackoverflow, but Y axis wasn't successful)
Possible Implementation
to fit with the current model, extending It's possible that the existing .getElementsAtEventForMode to treat the labels as elements would be the 'purer' mechanism, though I'd also love to see onClick / onHover methods as options as part of the data.labels definition
Duplicate of: #9602, #9627
You can also look at this SO answer for how to write a custom plugin to do all the detection: https://stackoverflow.com/a/75438712/8682983
Duplicate of: #9602, #9627 You can also look at this SO answer for how to write a custom plugin to do all the detection: https://stackoverflow.com/a/75438712/8682983
that SO solution appears to work for 3.x but not 4.x