Skip to content
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

[Feature Request] Easy way to retrieve the active item in the updatemenus (or retrieve any figure layout property without getting data) #1807

Open
meng-du opened this issue Oct 20, 2021 · 0 comments

Comments

@meng-du
Copy link

meng-du commented Oct 20, 2021

Is your feature request related to a problem? Please describe.
I'm wondering if it's possible to make it easy to retrieve the active item in the updatemenus of a figure, from a Dash callback. I am in a similar situation to this post: https://community.plotly.com/t/get-active-button-in-updatemenus/9021 . Basically I need to know which button/trace is currently active/visible, and I'd have to keep the same thing active when I update this figure. I also need this information when updating other figures in my web app. Therefore it is very frustrating when I realize there is no easy way to do this (correct me if I am wrong, though).

Describe the solution you'd like
Perhaps make either the active item (for example its button index) a property of a figure, or the entire layout as a property (if a more general solution is needed), so that it could be easily retrieved in Dash callbacks through something like State('my_figure', 'active_updatemenus_item') or State('my_figure', 'layout').

Describe alternatives you've considered
First simple alternative is to retrieve the active item by passing the entire figure to the Dash callback, and then get the active item in its layout. This could work but is extremely inefficient -- I have a huge figure in my case, and just passing all of those data to the callback function takes a few seconds (!) for my browser. I occasionally need to trigger this callback every 0.5 seconds, so this amount of time is unacceptable. For smaller figures, the amount of time might not be so crazy, but still it is unnecessarily slow.

Another alternative is to use a dcc dropdown menu instead of the updatemenus, but updatemenus is just so nice, elegant, and already works for my purpose perfectly (except for this one small issue). It would be sad if I have to reinvent the wheel for a small issue like this.

Additional context
See this post: https://community.plotly.com/t/get-active-button-in-updatemenus/9021

@meng-du meng-du changed the title [Feature Request] Easy way to retrieve the active item in the updatemenus [Feature Request] Easy way to retrieve the active item in the updatemenus (or retrieve any figure layout property without getting data) Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant