✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Update data inside Graph through updatemenus

Hi, there! I’m trying to update my Graph component, but nothing happened.

dcc.Graph(
    figure=go.Figure(
        data=Data_Coins['key'],
        ....
        updatemenus=list([
                dict(
                    type="buttons",
                    buttons=list([
                        dict(label='Label',
                             method='restyle',
                             args=['data', Data_Coins['key2']]))
     )

I’m using updatemenus to create buttons inside chart and when button clicked I want to change data of Figure.
As you can see I used method=‘restyle’. Also I tried to use ‘update’ method, but got the same result.
Thanks for help!

maybe dcc.Graph is not support … :open_mouth:

In your example, it looks like your setting:

go.Figure(
    data=[...],
    updatemenus=[...]
)

however, from the docs in https://plot.ly/python/dropdowns/, it looks like updatemenus is inside layout. So, it should be:

go.Figure(
    data=[...],
    layout={'updatemenus': [...]}
)

Hi Zendk
Were you able to get this working? I have a similar need, to be able t load new set of data based on a button click in updatemenu.

Is there another way to achieve the same thing?

Thx