Hello,
I have a plotly chart with multiple traces (dynamic) and I would like to enable users to select multiple traces to display on the chart when the chart is saved as html. I was able to do it in dash using a dropdown menu but I would like to do the same using layout.updatemenus. At the moment I can select a single trace at a time, but when I select another trace the previously selected trace is no longer visible.
Below is the piece of code, please note that the list โwaves_name_listโ is dynamic and very very long so I cannot cover all the combinations in the dictionary. Is there a way to enable multiple selections using layout.updatemenus?
visible_list = [True]*(3)+['legendonly']*len(waves_name_list)
waves_dict = [dict(label="All",
method="update",
args=[{"visible": [True]*(3+len(waves_name_list))},])]
for i, w in enumerate(waves_name_list):
mvisible_list = visible_list.copy()
mvisible_list[i+3] = True
mdict = {'label':w,'method':"update",'args':[{"visible": mvisible_list}]}
waves_dict.append(mdict)
fig.update_layout(updatemenus = list([
dict(
buttons=list(waves_dict),
direction='down',
showactive=True,
xanchor='left',
yanchor='top'
),
]))