Dynamic Charts in Tableau – (Using show/hide button)
In one of the previous posts, I shared how to create dynamic charts (better known as sheet swapping) using a parameter and a layout container to allow your dashboard consumers decide which chart is shown. Read the post here.
In today’s post, I would like to take a different approach to show you another technique of choosing which chart is shown using show/hide button introduced in Tableau 2019.2.
In this case, I would like to create a dashboard where user can swap between a bar chart and a line chart.
Creating a bar chart
In this case I have created a bar chart showing order year and Profit.
Creating a line chart
Recreating the same analysis but now using a line chart
Building the view
While on the floating mode – drag one of the above charts to the dashboard area.
Drag a vertical or horizontal layout container to the view – ensure it matches the chart in the view by resizing it to fit.
(Optional: For better results you can format the layout container background color to match that of the charts' background)
Drag now the chart to be hidden inside the layout container.
Select the layout container and add a show/hide button
Executing this Tableau adds a button on the view
We can edit this button to replace it with our own image.
To do so, select the button and on the drop down menu choose ‘Edit Button…’
On the pop up menu,
Select button style as ‘Image Button’
Button appearance as ‘Item Shown’
Choose the type of image you would like to show;
In this case I have chosen an image of line chart to be shown when my view is a bar chart.
Toggle your button to choose what will be shown when the item is hidden.
In this case I have chosen an image of a bar chart when my current view is showing a line chart (when the item (container holding the bar chart) is hidden)
Executing the above and changing the view to presentation mode, gives us the view below which changes anytime you click on the icon.
I hope this was helpful to you. To receive more of the Tableau tips and tricks, kindly subscribe to our mailing list below.
Thank you for reading.