-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Legend events #2581
Legend events #2581
Conversation
... and use their return val to determine whether or not the default handler is called after them. This allows users to disable legend trace toggling and/or augment it!
Not sure what that deprecation comment is about (@bpostlethwaite ?) but this seems like a clean solution to me. I don't see ^^ as a downside, in fact it's really the only option if you want to be able to avoid the default behavior in the first place right? I suppose we could make even more events (
referencing #1546 - if we're ever going to add
For use with our favorite transform, |
I think JQuery deprecated certain behaviours with triggerHandler for versions >2 but I can't find any reference to this with a quick search. IMO if this function has useful functionality or more importantly an intuitive and useful API then we can delete that comment. |
Currently (i.e. excluding the new events in this PR), So, I suspect when that comment about 🔪 |
Tagging this as
|
- add 'expandIndex' for all traces - add 'group' for traces with enable groupby transforms - 🔪 itemNumber (which was undefined on double click, can add it back in future if someone asks for it.
done in 02a85bf |
Oh maybe we wanted to deprecate |
|
Very nice. 💃 |
Are these new events in the docs somewhere? (I don't see them where I expected them to be.) |
@jacobq you can subscribe to plotly/documentation#937 |
This PR adds legend two events
plotly_legendclick
andplotly_legenddoubleclick
. Note that, as per @alexcjohnson 's recommendation in #65 (comment), these new events are emitted usingEvents.triggerHandlers
which allows users to cancel the default click/doubleclick behavior via the (last) handler's return value. This PR chose this strategy despite this note:plotly.js/src/lib/events.js
Lines 93 to 96 in 4ed586a
Is it fair to say
Events.triggerHandlers
is a good idea afterall or is there a better solution?Tagging this PR
discussion needed
as there are as few debatable things here:Events.triggerHandlers
? One drawback of using it: the custom handlers must be called before the default handlers, meaning the users won't have access to the to-be-updatedvisible
trace attribute values - which could be confusing for users that want to augment the default behavior (but maybe listening toplotly_restyle
is good enough for that use case?)plotly_legendclick
andplotly_legenddoubleclick
be the same event? For example, maybe both click and doubleclick could triggerplotly_legendclick
where the click/doubleclick distinction would be made using addition event data field (e.gnumClick: 1 || 2
). This would allows users to define their own click-vs-doubleclick timeouts.Referencing numerous related legend feature requests:
cc @jackparmer @willdurand