Data + Science

[ad_1]


6/19/2018
How to Make a Tadpole Chart and Other Charts in Tableau with Open Circles


I was reading a recent blog post The Spawning of the Tadpole Chart by Mark Edwards. Mark’s post outlines pros and cons for various styles of this chart, but he asked on this Twitter thread how to make the lines stop at the outer edge of the circles instead of going into the center of the circle. I’ve seen this come up before and I’ve attempted several different approaches for this over the years, so I thought I would share a few of those attempts and a simple solution that works well for creating these Tadpole charts and other charts in Tableau with open circle marks.

The Tadpole Charrt
Before we begin, here is a “Tabpole” chart that Emma Cosh mocked up (not built in Tableau).

This isn’t a new chart. In fact, this chart is featured in the Big Book of Dashboards in Chapter 8 in a dashboard created by Jonathan Drummey for Southern Maine Health Care. We struggled with a name for this chart in the book. Ultimately we decided it was a variation on a lollipop chart, a chart invented by my co-author Andy Cotgreave. Looking back on this, it serves the same purpose as a connected dot plot, also known as a dumbbell chart, but it’s plotted with a single dot.

Personally, I like the new name that Emma came up with for this line and single dot; the Tadpole chart, and building it is pretty straight forward. It starts as a dumbbell chart. However, the single dot shows the current period so there is no dot for the previous period. A dumbbell chart is fairly easy to build in Tableau. It requires a dual axis with one axis as the dots and the other axis as the lines connecting them. Eliminating one dot is also pretty easy. A simple calculation to check for the most recent period and make it equal to your measure when it’s the current period and NULL if it isn’t. Mark Edwards used this type of calculation to recreate Emma’s Tadpole chart and subsequent variations. You can download Mark’s workbook here and follow along.

   Calculated Field Name: Sales Circle
   Formula: IF [Period] = ‘This Year’ THEN [Sales Line] END

For the Superstore data, the calculation might look ike this:

   Calculated Field Name: Sales Circle
   Formula: IF DATEPART(‘year’, [Order Date]) = 2018 then [Sales] END

The tricky part, however, is how to make the open circles without having the line come into the center of the circle. For example, in one of Mark’s Tadpole chart variations it looks like this.

Notice the line goes through the circle and into the center of each circle. So how can we create the same chart in Tableau, but with a white center (or whatever background color)?

What Doesn’t Work Well

Before I offer a solution for this, I’ll share a few attempts that I tried over time that did not work well.

First, creating custom shapes. Typically, I suggest saving custom shapes as PNG files. So why not create a PNG file with a circle with a white center? The problem with this is that when Tableau encodes color on a custom shape that is saved as a PNG with a transparent background, it changes the color of the white center as well and you end up with a colored dot. So how about a JPG? The problem with a JPG is that the it can’t have a transparent background, so you end up with a solid colored square, instead of a circle. Besides, even if this worked, it would be a pain to create custom shapes with different colors to match the viz and background color. In addition, custom shapes are low resolution, so you can’t print or export them as high resolution in PDF or images.

What about changing the data? We could shorten the line away from the dot using calculations. This isn’t easy, because the amount of shortening could be a positive or negative number depending on which direction the Tadpole is going. Also, the amount to add or subtract from the line would be dependent on the size of the circle and the length of the line. As the circle gets bigger then more line needs to be removed. This approach would require a number of calculations and would be difficult to get just right.

Adam McCann had an interesting idea. He suggested adding a label on the inside of the circle with “l” and make it white. I thought of a variation on this might be to use a Unicode bullet character and make that white to fill in the circle. The problem I found with this was getting the labels to show exactly in the center of the dots and with the right font size.

So let’s look at another way we can build this chart.

Building a Basic Tadpole Chart

This is the easy part. Building a basic Tadpole Chart is pretty straight forward. Using Mark’s workbook, here are the steps to build a Tadpole chart..

   Move Sequence to Rows
   Move Sales Lines to Columns
   Move Sales Circle to Columns
   Right-click on Sales Circle and Select “Dual Axis”
   Right-click on the secondary y-axis and Select “Synchronize Axis”
   On the All Marks Card, Move Category to Color

   On the Sales Lines Marks Card, Select Line from the dropdown menu on the Marks Card
   Move Period to Path
   Right-click on the Y-Axis and select “Show Header” to remove the header
   Right-click on the Secondary X-Axis at the top and select “Show Header” to remove the header

You should now have a Tadpole chart that looks like this:

Adding a White Center to the Filled Dot

The best way I’ve found to create the circle is to fill the inside of the dot with white (or whatever color the background color is) with another circle. To do this, we are going to duplicate the Sales Circle field and overlay it over top of the current circle.

   Right-Click Sales Circle and select “Duplicate”
   Move Measure Values to Columns on top of Sum(Sales Circle). This will replace Sum(Sales Circle) with Mesure Values on the Columns.

You will now have four measures on the Measure Values card, but we only want two of them.

   Right-click Sum(Sales Lines) and select “Remove” or drag the pill to the left off of the canvas.
   Right-click Sum(Number of Records) and select “Remove” or drag the pill to the left off of the canvas.
   On the Measure Values Marks Card:
   Select Circles from the dropdown menu on the Marks Card
   Move Measure Names to Size
   Select the Detail icon to the left of Measure Names and change it to Color
     or Multi-Select Category and Measure Values holding down the Control Key and move them both to Color

You should now have 12 colors in your legend.

   Double-click any color in the color legend to open the edit color menu.
   Change all of the Sales Circle (copy) colors to white (or to match the background color) and assign the other colors as desired.
     Note – you can multi-select all of these using the Control key and then double-click the last one. This will change all of the colors at once without changing each one.
   On the Measure Values card, drag Sum(Sales Circle (copy)) to the top of the list ahead of Sum(Sales Circle). This will reverse the size of the circles. Or double-click one of the size icons in the legend and select “Reversed”
   Double-click one of the size icons in the legend and make the smaller dot (Sum(Sales Circle (copy))) larger.

You should now have a Tadpole chart with a circle and no line through the middle of the circle.

This same technique could be used for lollipop charts, dumbbell charts or any chart that combines lines and dots on a dual axis. In addition, the size can be reversed to put the white circle on the outside to create a gap between the dots.

A dumbbell chart with open circles:

A dumbbell chart with an open circle for the previous period and a filled in circle for the current period:

A dumbbell chart with the white circle on the outside creating a gap between the dots and the line:

A lollipop chart with open circles:

A line chart with open circles:

A line chart with white circles on the outside creating a gap between the dots and the line:

Below is a Tableau workbook I created based on Mark’s original workbook with all of these different chart variations:

I hope you find this information useful. If you have any questions feel free to email me at Jeff@DataPlusScience.com

Jeffrey A. Shaffer

Follow on Twitter @HighVizAbility



Read More …

[ad_2]


Write a comment