Black Lives Matter. Please consider donating to Black Girls Code today.

Creating drop down menus dynamically from radio item


I have a dataframe with n columns of categorical data and I want to make it so that the user can leave one axis free for subsequent exploring using a radio button and then can filter the remaining n-1 columns using dropdown menus of the unique values in each of these columns.

So for my dataframe I wold have a layour such as this

df.columns = ['col1', 'col2', 'col3' ... 'coln',  'value']
data_axis = [col for col in df.columns if not 'value' in col]
# data_axis = ['col1', 'col2', 'col3' ... 'coln']

I’m happy creating radio buttons to select one of the values of data_axis, but what I then want it to be that I generate the remaining n-1 dropdowns with each subsequent dropdown only containing the valid options left after making the selection in the prior dropdown. Again, I’m happy creating say, three static dropdowns that are each dependent on the previous selections, it’s the process of combining these ideas into one thing i’m struggling with.

In particular it’s the process of creating the n-1 dropdowns that I cannot wrap my head around/find any good resource so any guidance/pointing to a useful resource would be great!

A complete newbie to DASH, but for what it’s worth I’d first do it the typical approach of having one drop down per data item. So you’d have two drop downs where the user could pick any item for the axis. You make as many dropdowns as you want series to appear on the axis. I can see the benefit of showing the user the possibilities with the radio buttons, but I feel it would look a little wonky have a combination of radio buttons and dropdowns.

If you had to have the drop downs, then my guess is in the callback you’d built a list of all columns based on which radio button was select then have that fill in the drop down with remaining, as you said. If you post more code I believe more people would comment.