Exercise

Extending the chain

Your conditional dropdown was a smash hit! That really cleaned up the dashboard and continues to provide a much nicer user experience. When demonstrating this product, the stakeholder asked if you could implement a few updates.

Firstly, they wish to have a default value selected for the minor category, so the graph always has something appearing. You have an idea of how to achieve this by inserting an additional chained callback in between the first two created.

Secondly, they wish to have a title below the graph that reminds users what major category the chosen minor category belongs to. Rather than another callback, you think this can be achieved by sending the chosen major category to an additional output.

Instructions

100 XP
  • Create a callback below line 48 that is triggered by a change in the major category dropdown, which will output to both the minor category dropdown and the html.H3().
  • In this callback function, create a string using the input chosen major category below line 62.
  • Return both the options created on line 58 and the title created on line 63 in the callback function below line 65.
  • Create a callback below line 68 that will pick a randomly chosen value for the minor category dropdown whenever the options for that dropdown are set.