Hi, I am using the code below to enable the user to choose between two series to see, basically, and even though active=0
is set, the graph keeps showing me both lines at first. Then, when I click on buttons, they do work, but I had interpreted the active
option as an init value for the buttons selection. What am I missing?
Thanks.
updatemenus = list([
dict(type="buttons",
active=0,
buttons=list([
dict(label = 'First',
method = 'update',
args = [{'visible': [True, False]}]),
dict(label = 'Second',
method = 'update',
args = [{'visible': [False, True]}])
]),
)
])
1 Like
Anyone has a clue on this?
Hi there,
active
refers to how the button/menus appear (https://plot.ly/python/reference/#layout-updatemenus-active). To get only one trace to appear at first you must set the traces’ visible
attribute (https://plot.ly/python/reference/#scatter-visible). visible=True
is the default so setting visible=False
on the trace that you don’t want to show up initially will hide it. The example here: https://plot.ly/python/custom-buttons/#update-button provides the logic for hiding some trace options on the initial load.
2 Likes
I’m having a similar issue.
I’m using updatemenus and the update method to hide or show tables depending on what the user selects. However, when I first open the page no matter what I put in ‘active’ it will always show the table which the argument is False.
When I open the page, the table that is showing is the last ‘False’ and not the first ‘True’.
updatemenus = list([
dict(active=0,
x=0.6,
y=0.65,
buttons=list([
dict(label = 'Gross Sales by Week',
method = 'update',
args = [{'visible':
[True, False, False,
False, False, False,
False, False, False,
True]},
]),
Does anybody know how to solve this problem?
Could you please post the updated code that worked for you with visible=False? I am running into a similar issue. Thanks!
Hi there,
Sorry… It’s been a while. What I understand from this
To get only one trace to appear at first you must set the traces’ visible
attribute (Single-page reference in Python)
is that you need to set visible=True
or visible=False
in the trace itself and not in the updatemenus
attribute.
Can you try it out?
That worked! Thank you girardea!
1 Like
Setting the visible parameter at the trace level solved the issue for me as well.
Thanks !