A couple of Tableau community projects caught my eye this week for which I thought there might be a nice cross-over. This month’s #SportVizSunday topic, with data courtesy of Rob Radburn, was on the Tour de France; and the topic of this month’s #SWDchallenge was to create a radial data visualisation.
With the above two topics in mind, I had the idea of creating two radial charts to form the wheels of a bike, which could then become the central piece of a Tour de France visualisation. It probably goes without saying that ‘visual best practice’ didn’t play a huge part in this decision making process, but nevertheless I thought it would be a fun project, especially as I don’t think I have ever published a radial visualisation before, so this would also be good practice – as I’d get to make two of them!
So, with the general idea in place, I set about reminding myself how trigonometry works.
Fortunately, while my memories of the hypotenuse had faded somewhat since my school days, I did remember that Ken Flerlage had recently written a very good blog post about all things trigonometry, which helped me get back up to speed.
With my newfound (or at least newly refreshed) knowledge I created the below calculations for the first radial chart:
There’s 360 degrees in a circle and I have 95 rows of data – one for each unique year in the data set – so one is divided by the other to get the right spacing between the points in the circle (which will eventually becomes lines, from the centre outwards):
Each successive point around the circle needs an extra space, so the space is multiplied by an INDEX(), which is calculated along the YEAR dimension:
Angle – Radians
As Ken discusses in his blog post, Tableau requires angles to be in radians, therefore a simple conversion calculation is needed:
As I am creating a radial bar chart, I actually need to two circles made with 95 points each, which are then connected with 95 lines, each starting at the inner point (at or near the centre) and ending at their respective outer point. In order to do this I duplicated the data by performing a self-union. To do this, when you connect to a an Excel sheet (table) in Tableau, drag the same table out again underneath the existing table and drop on the message “Drag table to union”:
Below is a snapshot of some of the data after performing the union. Note the addition of an auto-generated field called “Table Name“:
The field value “TDF” represents the original data and “TDF1” represents the copy. These values can be used in a conditional calculation to generate two radius values; one for the inner circle of points, which will all be the same value, and one for the outer circle of points, which will be the value I want to represent with the line – in this case, the Average Pace field:
To help with sizing the circles later on, I used a parameter in the calculation with a value of 7 in this case.
X and Y points
Finally, I needed the X and Y calculations for each point. Not wanting to reinvent the wheel here (despite the topic at hand), I’ll once more suggest taking a look at Ken’s blog post for more details on what these calculations are doing:
These calculations could then be placed in the view as below to create the radial chart (all table calculations are calculated along the Year dimension):
Highlight Fastest and Slowest
I added an extra calculation, placed on to the Colour card, to highlight the highest and lowest values:
I also added the Table Name dimension on the Size shelf so that the lines would become slightly thicker as they progressed outwards.
Labels and tooltips were added and then the whole chart was duplicated and updated, swapping the Average Pace measure for the Distance measure. With my two radial charts – my two ‘wheels’ – ready, I then added a simple bicycle image in the background, placed the wheels on and added some supporting text.
To aid in understanding and to provide a different view of the data, I added two line charts of the the same measures – Average Pace and Distance – below the radial charts (which arguably makes the radial charts somewhat redundant, but let’s not get bogged down in details). I also thought the line charts kind of look a bit like a road surface for the wheels to be on. A little bit. Maybe.
The final visualisation is below. Click the image to open the interactive version in Tableau Public:
Animating with the Pages Shelf
By adding Years to the Pages shelf, it was possible to show the lines move around in a circle to (kind of) see the wheels turn…
Update: The day after publishing the above visualisation, I received a nice surprise to see that it had been named Viz of the Day (#VOTD) by @tableaupublic
Latest YouTube video
This video demonstrates combining Cloudinary’s dynamic image creation service with Tableau’s new Image Role feature.