Viz Design Secrets: Expanding and Collapsing Containers in Tableau
Recently, I created a dashboard at my company, Lovelytics, that shows the State and County popular votes in the past elections. What’s neat about this dashboard is that the main map is at the State level; however, once a user selects a State, the County map appears along with a bar chart on top county votes. To create this level of interactivity within Tableau, I used two things – containers and dashboard actions.
For many Tableau users, containers are one of those topics that may be tough to grasp at first. Therefore, I intend to use this blog post to simplify containers and step through how I used them to add interactivity within my dashboard (shown in the clip below). Please note that there are many use cases for containers. This blog reflects just one of many!
What is a Container?
Layout containers are objects, located on the dashboard pane, that allow you to group related dashboard items together. As you change one of the items in a container, the other items in the container automatically adjust. There are two types of containers – a horizontal container and a vertical container. A horizontal container allows you to group worksheets and objects left to right. A vertical container allows you to group worksheets and objects top to bottom (up and down). A container is the only dashboard object that will highlight with a blue border instead of a grey border when selected. Check out the image below.
What goes into a Container?
You can place worksheets and other dashboard objects such as text boxes, blank objects, images, web pages. Simply drag a container to the canvas and then drag an object inside of the blue box. View the clip below.
You can even place containers within containers *gasp*!
This is exactly what I used in the State and County Votes visualization – a vertical container within a horizontal container. This container within a container option allowed me to add charts BOTH left to right AND top to bottom.
How to Add Interactivity and Expand/Collapse a Container?
Before adding interactivity, I hid the titles on the County Map and the Top County Votes bar chart. I’ll explain more about this below. Next to add interactivity, I highlighted the State Map on the dashboard and selected the “Use as Filter” icon. I then selected “Dashboard” in the toolbar and changed the auto-generated filter to “Exclude all values” once the filter is cleared. I made sure to also de-select the charts that I did not want this action to apply to. View the process below.
Things to Keep in Mind
There are two things that I learned when expanding and collapsing containers in Tableau:
1. You must hide titles on the worksheets that you want to exclude. This is the only way that the main worksheet can fully expand once the exclude filter is applied. View the clip below to see what happens if you do not hide titles before applying the Exclude option.
2. Do not manually adjust the worksheets once you have added them to containers. Doing so will fix the width of your worksheet and disable it from fully expanding or collapsing. However, if you happen to manually adjust the container, simply deselect the pin icon of the worksheet and it will return to auto width. View the clip below for details.
Hope that helps you all get started with expanding and collapsing containers. Check out the final version of my dashboard below! Happy Vizzing!