6

Five Ways to use Images in Tableau – datavis.blog

 3 years ago
source link: https://datavis.blog/2020/12/24/five-ways-to-use-images-in-tableau/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Five Ways to use Images in Tableau

This post, and the associated workbook, will show you five ways of adding images to your Tableau dashboards:

  1. As a shape on a worksheet
  2. As a shape in a Viz-in-Tooltip
  3. In a dashboard web object using a URL Action
  4. As a background image in the view
  5. As dashboard image objects

A built example of each of these methods can be found in the associated workbook, which you can interact with and download from Tableau Public here. Looking through the workbook is the best way to understand each method used in detail. The below post will give a high-level overview of the steps involved in each method.

Adding Custom Shapes to Tableau

The first two methods make use of custom shapes, so let’s first look at how you add these to Tableau:

  1. Find or create ideally small/low resolution images that you want to use in your dashboard
  2. Copy the images from your computer and paste them into a sub-folder within the Shapes folder of your Tableau repository

For these examples, I created a new folder called Christmas as the images are of that theme. This allows me to easily find them within Tableau. If you’ve customised the location of your repository, the path will be different, otherwise it will be the default which is shown in the image below:

These images are now available as shapes in Tableau desktop along with all the other shapes (note, you’ll need to click the Reload Shapes button for your new folder and images to appear if Tableau is already open):

Data Source

I’m using two simple data sources, each with 3 rows, which I’ll use to assign shapes to and for various dashboard actions:

1. As a Shape on a Worksheet

This method uses the following steps (see the workbook for more details):

  1. Create a parameter with 3 values. I’m using: Bauble 1, Bauble 2, Bauble 3
  2. Add the parameter to the view on the Shape shelf
  3. Assign the relevant custom image to each value of the parameter (you can only assign one at a time to the current parameter value, so change the parameter value then assign the next shape).
  4. Create a second view with the Picture field on rows and use this with a parameter action to change the value of the parameter
  5. When the parameter changes, the images changes

2. As a Shape in a Viz-in-Tooltip

The steps used for the method:

  1. To create the Viz-in-Tooltip worksheet, first put the Picture field on rows
  2. Set the mark type to Shape
  3. Add the Picture field to the Shape shelf and assign the relevant custom image to each picture
  4. Now all three images will show in the view.
  5. Create a view similar to the previous example with 3 marks in the view using the Circle mark type
  6. Open the tooltip editor and insert the Viz-in-Tooltip sheet just created
  7. Now, when you hover over one of the circles, a filter is automatically applied so only one image shows in the Viz-in-Tooltip:

3. In a Web Object using a URL Action

Steps used for this method:

  1. Upload your images to a hosting service such as imgur.com
  2. Copy the URLs for the hosted images and put them into your data source as a URL field
  3. Create the same view as before with three circles
  4. Add the URL field to the Detail shelf
  5. Add this view to a dashboard
  6. Add a Web Object to the dashboard (leave the URL blank)
  7. Create a URL dashboard action and pass the URL field to the Web Object

When you hover over each circle, the URL for the Web Object updates and a new image is loaded.

From a performance perspective, I’ve found this method works very well and images load quickly.

4. As a Background Image in the View

This method is less well know but can work really well in certain situations. One business use case is for visualising data on top of a floor plan images, which you can change to show different floors of a building for example. However, for this example, we’ll be staying with the Christmas theme:

  1. As before, create a simple view with three circles using the Picture field (I’m using the second data set with three tree images this time). This will be used to pass the Picture value to a parameter using a parameter action.
  2. Create a second view with X on Columns and Y on Rows – these values are used to position the background image
  3. Create a parameter based on the Picture field so it has three values
  4. Create a calculation called Background that equals the value of the parameter and place this on the Detail shelf
  5. Go to Map > Background Images and select the data source used in the view (Trees in the case)

6. Click Add Image… and browse to the image you want to use and assign the values 0 and 1 to the fields X and Y as shown below.

7. Click the Options tab then click Add… to add a condition:

8. In the popup dialog select the Background calculated field that was added to the view earlier:

9. When you select the field, you will then be prompted to select a value that is present in that field. The background image will then only show when the field has this value. Because this field is taking the value of the parameter, only one value will be shown – the current parameter value (White Tree in this case):

10. Click OK on the dialogs to get back to the view. Then fix the X and Y axes to go from 0 to 1. This will ensure the image fills the view.
11. Change the parameter value, then follow the same steps above to add the other two images, with the relevant conditions. You’ll then have three Background Images, each with a different condition:

Now when you hover over the three circles, the parameter value is updated, this changes the value in the calculation and that determines which background image is shown:

5. As dashboard image objects

The final method is the easiest of all and simply involves dragging Image objects into the dashboard from the side panel:

When your drag one of these to the dashboard, a popup window appears for you to browse to the image file to show in the image object:

You can then resize the image object and add borders as needed, just like other dashboard objects. In the example below I have one large image object with three smaller image objects floating on top:

Conclusion

Again, I’d recommend exploring the associated workbook for this post to look through all the dashboard actions involved and other settings. Each method has its benefits depending on the situation and the desired effect.

The main advice I would offer is to make sure your images are small in size to ensure a quick load time. I’ve found the URL action method with a Web Object is very quick, though it’s not suitable for all use cases. As an example of where I’ve used this method, below is a section of a visualisation of a travel map I made recently, where you can hover over a point on the map and show a photograph of that location:

Thanks for reading!

Marc Reid
Twitter | Linked In | Tableau Public


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK