0

I want to add percentage valued dropdown in plotly graph and after selection of option wanted to pass it to my function

um = [
    dict(
        active=-1,
        buttons=list([
            dict(label="40",
                 method="update",
                 args=[]),
            dict(label="60",
                 method="update",
                 args=[]),
            dict(label="80",
                 method="update",
                 args=[]),
        ]),
        x=1,
        y=1.2
    )
]
fig.update_layout(updatemenus=um)

def get_value(high): 
     print(high)

Here i want to get value 80 when option is selected and pass to a function get_value() for futher processing to update graph

  • I'd need a lot more information about what you're doing to come up with a great answer. However, if you're using Jupyter [check out this resource](https://plotly.com/python/click-events/). If you're not using Jupyter, you can add JS by importing Plotly io. The function `write_html` has the argument `post_script`, which allows you to append JS. You can also choose to have it immediately open in your browser, as well. Although it will still save an external file. – Kat Dec 03 '22 at 16:41
  • It's a bit hard to tell what you are trying to do. When you say "further processing to update graph" what kind of update do you mean? if you are trying to do something fairly complex in your function, then you would probably need to restructure your code using `plotly-dash` and make your function a callback that can update the data or figure. – Derek O Dec 05 '22 at 03:26

0 Answers0