Radar Charts in Tableau – Part 3
I’m going to return to the concept of Radar Charts today, with part 3 of the series – you’d never imagine that we could keep talking about such a Tableau-taboo chart type, but we have!
To refresh, in Part 1 I showed how you could use a background image for the ‘web’ of the chart, whereas in Part 2, Chris used Alteryx to create the background image. I was considering showing how you could create the web in R, but Phillip Burger made that unnecessary.
So, where can we go from here? The obvious step is to do away with the background images, and bring the web creation into Tableau itself. Sounds simple, and in theory it is. However, I wanted to also make something that could easily be picked up and dropped into any workbook without required a high level of skill to implement. I wanted the solution to have that “Tableau” feel to it, which is a concept I am coming to appreciate recently more and more.
So without further ado, I present my solution – I’ll go into more detail after. One point – since I’m producing a tool, I’ve purposefully used fake data, so don’t try to gain great insight into the cars!
Still here? Hopefully the viz has sparked your interest. Next steps – how it is made and how to use it
How the viz was made
The first point is obviously the data – without the right data, the viz can’t happen. The method I went for is to separate the background data and the chart data in an excel file, so that the chart data can easily be updated without worrying about breaking the background image. The two strands of data are then stitched together with custom SQL so that we have a single data source in Tableau that contains all the data.
The sharp eyed among you may have noticed that the image above shows the underlying data containing far more radials than the resultant viz. This is to allow the radar chart to automatically grow to as many metrics are included in the data, up to a total of 20 radials. There are two parts to the background – the radials and the rings.
These exist on the zeroth ring, and use the Spindle Point dimension to go from 0 (centre of the chart) to 1 (110% of the extent of the data). The number of radials depends on a count of the number of metrics that are present in the view at any one moment. This is done by using one table calculation to determine the number of metrics for each of the data dimensions, and then we wrap that in another to allow all elements of the viz to access this number
Once we know the number of radials we are plotting, we then need to know how to arrange them. Using the previously calculated number of radials, we can just divide that into 2PI to get the angle between each one. Note that Tableau works in Radians, so for those of you that are used to 360degrees, sorry!
Using this, we can now work out the X and Y co-ordinate of the points on the radial line using basic trigonometry:
X = length * SIN(angle)
Y = length * COS(angle)
A line is then drawn for each radial and we move on.
Next step is add the rings to connect each radial. The last ring is at 100% of the maximum of each measure, and the rest of the rings are equally spaced between the maximum and the centre. The number of rings is determined by a parameter, which is currently surfaced on the viz. To make the calculations easier, the rings don’t need to know about what the maximum value is, as the length for the maximum is fixed at 1, so the length for each ring is just
Using the same trigonometry calculations as before, we can get the X and Y co-ordinates that we join up for each ring.
Finally, we move on to the data. The idea is to map each metric onto the corresponding radial. To do this we need to number the metrics, but as we want to be able to filter the metrics on the fly, we need to make the numbering dynamic, after the filtering. This means table calculations, and in this case, we turn to the INDEX function.
If ISNULL(Min([Radial])) Then INDEX() End
Utilising similar steps as for the background, we use the metric number to work out the angle, the metric value vs the max value to work out the length, and then the angle and length to provide the X and Y coordinates.
These points are then used to create a polygon for each dimension.
Putting it all together
Using the combined X field and the background Y field, we start off by creating the background lines, and then dual axis this with the Y field for the metrics.
Things are looking good, but we need some additional tweaks to bring a bit more polish.
- The metrics are added as a dimension filter
- The dimensions are added as a table calculation filter. This is to allow dimensions to be selected without resetting the maximum value for each metric
- Labels to indicate what the maximum for each metric is. This is a little tricky, with each background radial looking for the maximum for the corresponding metric, and what that metric is called
How to use this viz
As I mentioned earlier, this was designed to be easy to move into another workbook. The way to do this is to modify the underlying data.
- Download the twbx workbook from Tableau Public.
- Download the Radar Chart Data. Open the excel file. Do not touch the Radials or Rings tabs. Modify the data within the Data tab, without changing the structure, though you can alter the number of metrics for each dimension
- Save the excel
- Open the workbook. Try to refresh the extract. At this point it will ask you to provide the new file location. Just point it at your modified excel. The extract will be refreshed, and the dashboard will show your data on a radar chart.
I hope that was clear and that now if you are asked to produce a radar chart, you can have this sitting up your sleeve for an easy win. Of course, this again doesn’t cover the fact that a radar may not be the best way to visualise the data, but this was more about being able to easily make what you need to for your audience. And hopefully I succeeded in making it have the Tableau feel.
And there we go. Radar Charts done in Tableau. Let me know what you think.