Linking Bar Charts and Drop-Downs
Explore how to link drop-down menus with bar charts in Dash to build dynamic, interactive visualizations. Learn to use callback functions including handling PreventUpdate exceptions, constructing app layout with rows and columns, and creating both horizontal and vertical bar charts based on user inputs. This lesson enables you to integrate controls that filter data by year and country, helping you design responsive dashboards that effectively compare values.
We'll cover the following...
We now want to put everything together that we’ve done so far. The plan is to have two drop-downs side by side with a chart underneath each. The first will provide years as options that will generate a horizontal bar chart. The second will generate a vertical bar chart based on the selected country. The end goal is to produce a new section in our app that looks like the illustration below:
Building the application in JupyterLab
Let’s start by building this as a complete and independent app in JupyterLab and make sure it works as expected.
-
Lines 2–9: We first run the necessary imports and instantiate the app. We already ...