1. Learn
  2. /
  3. Courses
  4. /
  5. Building Dashboards with Dash and Plotly

Connected

Exercise

Conditional dropdown options

A senior purchasing officer in the e-commerce company has posed an interesting problem. Their existing dashboard, showing sales by month for minor categories of items, has a two-level dropdown (major category and minor category) with way too many options in it. It is especially annoying, you are told, that some options appear in the second dropdown that can not be selected.

You assure the stakeholder you can assist - it is an excellent opportunity for you to use chained callbacks to produce a conditional dropdown.

Instructions

100 XP
  • Create a callback below line 31 to update the minor_cat_dd dropdown options based on the major_cat_dd dropdown value.
  • Reformat the relevant_minor_options variable (below line 39) into a list of dictionaries with identical label and value keys.
  • Create another callback below line 43 that updates the sales_line graph figure based on the minor_cat_dd dropdown value.