Swapping Image in Bar Chart – New levels of Tableau visualization!

The following blog depicts the technique created by Alex Jones (@jusdespommes) blog about “How to… create a chart from an image in Tableau!”.

Many of us are getting bored of seeing normal plain bar charts. What if we could add image to a bar chart – Pretty cool right? We can now swap between images with a little bit extended trick using ‘Show/Hide Containers’ feature introduced in Tableau 2019.2

top-25-countries

Show/Hide Containers

Tableau 2019.2 has introduced an option to show/hide containers (when the container is a floating type). Many experts have come up with different use cases such as hiding and showing the filters, parameters, or even a worksheet with a click which occupies much space in the dashboard using this feature.

dashboards

This feature is pretty simple to use and comes in handy when we want to save some space in our dashboards.

How to Swap image in Bar Chart?

1.Create a simple bar chart in Tableau 2019.2. We have used “Top 5 Grossing Games Worldwide 2018” to create a bar chart and sorted based on the revenue.

Top-5-Grossing-Games

2.Remove the label, header and export the worksheet to image. Worksheet > Export > Image (Choose ‘view’ in Export Image dialog box)

Export
Export

3. Open Photopea, which is an online photo editor and open the saved worksheet image.
File > Open > Image

Top-5-Grossing-Games

4. Now, download 2 images from online which we are going to use for bar chart.

ExportExport

5.Copy and paste image 1 on top of the bar image. Now we will be having two layers of images one above another.
(We can even re-position, crop the image if needed)

Export
Export

6.Choose ‘Magic Wand’ from the tool bar at left side. Click on the image, and we can see the selection in dotted lines.

Export
Export

7.Choose the top layer (image 1) and click delete. Now we can able to get the below image.

Export

8.The background of the image needs to transparent. So, delete the below layer (bar chart image) using delete icon at the bottom right corner.

Export

9.Now, choose File > Export as > .PNG to save the image as .png format (this will retain the transparent layer)

Export

10.Repeat the same steps with image 2 to get the same effect.
Note: Keep the same resolution and image size as the previous one.

Export
Export

10.1.Now, open Tableau Desktop and bring in the image as floating type.

Export

11.We have to position the bar chart over the image. To make it easy, decrease the opacity of the bar chart and give border.

Export
Export

12. Add labels and tooltip to the bar chart.

Export

13.Now the dashboard looks like this. We can able to hover on bars to see tooltip.

Export

14.Now, comes the trick of using ‘Show/Hide Containers’ to swap image. Bring a container to floating and add image 2 to the container. (Set the padding to zero)

Export

15.Next, we have to position the both images and the bar chart one above another. To make it easy, use x, y axes and size w, h to position accurately.

Export

Note: Make sure the position of the 3 objects (Use Floating Order) follows the below order as all are in floating.

  1. Image 1 (Below layer)
  2. Image 2 inside container (Middle layer – where show/hide option is to be used)
  3. Bar Chart (Top layer)

Export

16.Choose the container and right click at the top right corner. Enable ‘Add Show/ Hide Button.’ Now we can see a floating button.

Export

17.We can customize the button by adding image and tooltip to buttons.

Export

18.We have used below customized images (created with PowerPoint) for buttons to swap between 2 images.

Export

19.Another simple trick is that we can control the transparency of the image by adjusting the opacity of the bars.

Export
Export

20.Take a look at the final dashboard….

  Beinex – UAE
Bay Square, Building No-1
Office 707, Business Bay
Dubai – United Arab Emirates
Phone: +971 4 243 9494
Mobile: +971 56 167 4790
Fax: +971 4 818 7280
Email: Info@beinex.com

  Beinex – UK
46-48 E Smithfield
Whitechapel
London E1W 1AW
Phone: +44 7539 393552
Email:UK@beinex.com

  Beinex – India, Kochi
#19, Ground Level
Infopark TBC, JNI Stadium
Kaloor, Kochi
Kerala 682017, India
Phone: +91 484 4855800
Mobile: +91 920 7204499
Email: Info@beinex.com

  Beinex – India, Bangalore
WeWork – Block L
Embassy Tech Village
Outer Ring Road, Bellandur,
Bengaluru, Karnataka
India – 560103
Mobile : +91-88834 82555
Email: Info@beinex.com

X