Custom Button based on "value" of another custom button


#1

Hey, I’m currently using Plot.ly offline in a BI Tool (Mode Analytics) and am trying to great a “nested” button.

I have a timescale graph where the buttons update the “store” that the data represents. I’d like to have a 2nd set of buttons (Daily, Weekly, Monthly) that update the timescale grouping for the “selected” store.

To accomplish the functionality of the first graph, I have traces for all stores (ie data = [store1, store2, store3]) and based on the button selected, I call args=[{'visible': [True, False, False]}] (where True corresponds to the correct trace based on the button clicked).

I can create a trace for the different groupings (ie data=[store1_daily, store1_weekly, store1_monthly, store2_daily, store2_weekly, store2_monthly, store3_daily, store3_weekly, store3_monthly]), but can’t figure out how to know what store is currently “selected” to then target the proper grouping (ie if Store2 is the current “selected” store, then if “weekly” is clicked, set something like arts=[{visible: [False, False, False, False, True, False, False, False, False] }] (where “True” targets store2_monthly ). Also, I have no idea if this is even the correct way to do this.

Any thoughts?

Thanks,
Walker


#2

Hi @wlangley,

Unfortunately this isn’t something that’s possible with the built-in plotly wigets (the ones defined in figure.layout). For standalone usage this can be done with a FigureWidget (See https://plot.ly/python/figurewidget/) in the Jupyter Notebook or with Dash as a standalone web application (See https://dash.plot.ly/).

Hope that helps clarify things,
-Jon


#3

Thanks @jmmease. I hadn’t seen the Figure Widget before.

Do you know if it’s possible to pass a function to the args parameter (I looked for documentation on args but haven’t found anything, but now that I think about it I guess as long as the function returns any arguments that are available in the defined trace…)? I’ve seen some examples where things were hacked by calling a function that explicitly set the x and y parameters and I’m wondering if I could do something similar by setting a global variable and then re-constructing x and y params in the function.