Using background images

Background images allow you to plot data on top of any image. Consider the possibilities! You could plot ticket sales by seat on an image of a stadium, room occupancy on the floor plan of an office building, the number of errors by piece of equipment on a network diagram, or meteor impacts on the surface of the moon.

In this example, we'll plot the number of patients per month in various rooms in a hospital. We'll use two images of floorplans for the ground floor and second floor of the hospital. The data source is located in the Chapter 11 directory and is named Hospital.xlsx. It consists of two tabs: one for patient counts and another for room locations based on the x/y coordinates mapped to the images. We'll consider shortly how that works. You can view the completed example in the Chapter 11 Complete.twbx workbook or start from scratch using Chapter 11 Starter.twbx.

To specify a background image, use the top menu to select Map | Background Images and then click the data source to which the image applies (in this example, Hospitals). On the Background Images, screen you can add one or more images.

Here, we'll start with Hospital - Ground Floor.png, located in the Chapter 11 directory:

You'll notice that we mapped the fields X and Y (from the Locations tab) and specified the Right at 800 and Bottom at 700. This is based on the size of the image in pixels.

You don't have to use pixels, but most of the time it makes it far easier to map the locations for the data. In this case, we have a tab of an Excel file with the locations already mapped to the X and Y coordinates on the image (in pixels). With cross-database joins, you can create a simple text or Excel file containing mappings for your images and join them to an existing data source. You can map points manually (using a graphics application) or use one of many free online tools that allow you to quickly map coordinates on images.

We'll only want to show this blueprint for the ground floor, so switching to the Options tab, we'll ensure that the condition is set based on the data. We'll also make sure to check Always Show Entire Image:

Next, repeating the preceding steps, we'll add the second image (Hospital - 2nd Floor.png) to the data source, ensuring it only shows for the 2nd Floor.

Once we have the images defined and mapped, we're ready to build a visualization. The basic idea is to build a scatterplot using the X and Y fields for axes. But we'll have to ensure that X and Y are not summed because if they are added together for multiple records, we'll no longer have a correct mapping to pixel locations. There are a couple of options:

  • Use X and Y as continuous dimensions.
  • Use MIN, MAX, or AVG instead of SUM, and ensure that Location is used to define the view level of detail.
  • Additionally, images are measured from 0 at the top to Y at the bottom, but scatterplots start with 0 at the bottom and values increase upward. So, initially, you may see your background images appear upside-down. To get around this, we'll edit the y axis (right-click and select Edit Axis) and check the option for Reversed.

We also need to ensure that the Floor field is used in the view. This is necessary to tell Tableau which image should be displayed. At this point, we should be able to get a visualization like this:

Here, we've plotted circles with size based on the number of patients in each room. We could clean up and modify the visualization in various ways:

  • Hide the x and y axes (right-click the axis and uncheck Show Header)
  • Hide the header for Floor, as the image already includes the label
  • Add Floor to the Filter shelf so that the end user can choose to see one floor at a time
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.76.164