Why is there a limitation for one callback per Output for Event type trigger?
I want to have multiple buttons to affect the same dropdown (control the value of dropdown with a click of one of the buttons) but dash does not like to multiple callbacks to control the same Output.
Is there a workaround?
I want to have multiple buttons to affect the same dropdown (control the value of dropdown with a click of one of the buttons) but dash does not like to multiple callbacks to control the same Output.
Could you just use multiple input elements to update the same output element?
Note that this type of behaviour with events
isn’t well supported right now and will likely change in the future. If possible, I’d try to see if you can describe your UI in a different way using just dash.dependencies.Input
elements instead of Event
s. For example, instead of several buttons affecting the value
of a dcc.Dropdown
, could you use a single dcc.RadioItems
instead?
Thanks for your reply Chris.
dcc.RadioItems would be an obvious solution, but I am trying to build a slightly more complex UI.
I have multiple histogram charts (for each “supporting” dimension of my data) and the main TimeSeries chart. I want to split other charts by any supporting dimension.
So from UX-design, it would make more sense to place a button next to each histogram, instead of one ugly global dropdown or radioButton.
So something like that might do the trick (if button can pass clickData True/False data):
def set_dimention(*clicks):
for i, click in enumerate(clicks):
if click:
return i
app.callback(
Output('dim-selector', 'value'),
[Input('country-button', 'clickData'), Input('platform-button', 'clickData'), Input('segment-button', 'clickData') ]
)(set_dimention)
So that clickData would be True/False, depending on what was clicked. (that code wouldn’t work, of course).
Even easier way would be to allow multiple callbacks per one Output.
Thanks,
Vlad.
Basically you desire a click state to be in the json returned by the action. I think this can be accomplished with a custom component, but it seems like a feature need in all action data. For example, when users click/hover/select the same inputs again. It would be good that the UI not update, especially if it’s a complex update.
I have a very similar issue. Did anyone find a good workaround? Thanks!