My First Radial Diagram

My First Radial Diagram

After the recent Workout Wednesday polygon exercises, which relied on calculating x and y coordinates, I decided to try my first radial diagram. Can’t be that difficult, right?

Actually, it was pretty easy! It just needed a bit of clear thinking about the calculations.

Before I get into how it was built, you can see it on Tableau Public and below:

Back to school – Trigonometry

Full disclosure: I LOVED this stuff at school! And still do.

I created the diagram using circle marks as it would be the simplest. I only need to work out the radius and angle for a single point for each data point. From these, we can work out the x and y coordinates that we need for Tableau to plot:

We mostly think about angles in degrees (0 to 360), but by default Tableau works in radians. This means that the top of the circle (“12 o’clock”) is 0 radians and 2 Pi, i.e. approximately 6.18 radians, with the 3 o’clock position being around 1.57.

The calculations for x and y are:

x = Radius x SIN(Angle)
y = Radius x COS(Angle)

So now I just need to work out what my radii and angles are.

Giving the user control

For this example, I’m using the standard Superstore dataset and using the date field for the radii and angles, letting the user select which dateparts should be represented going around the circle (angles) and going out from the centre (radius). Conveniently, Tableau allows us to use parameters as dateparts directly in it’s date functions. Both parameters were configured the same:

The parameter in, for example, a DATEPART calculation looks like this:

DATEPART([p.Around the circle], [Order Date])

This would be all that I need for the radius calculation were it not for the years. The other options go from 1-7, 1-365, etc, but the years go from 2016-2019, so to make the year values more usable I added an extra if statement. My Radius calculation now looks like this:

For the angle, I need to equate the maximum value of the Datepart, e.g. 12 to 2 Pi. So, if I’m using ‘month’ and I’m plotting June (value 6), then the result should be half way around the circle, i.e. have an angle of Pi (3.14…)

I need the same fix for when years are being used, giving me a calculation for the angle of:

Squaring the Circle

Dragging x to columns and y to rows (note: NOT SUM(x), which is the default!) gives the following result:

It all looks a bit squished. I’d seen somewhere that to square up the chart area, you need to use a square-shaped background image. And then it struck me, why people need transparent 1×1 pixel images!

I downloaded an image from 1x1px (being lazy!) and added this to the background. In the menubar, click Map / Background Map / Then select the database, in this case Superstore. Click on Add Image in the dialog box:

Browse to the transparent 1×1 pixel image and select it. Now you have the chance to force Tableau to display the chart with the proportions that you want. I entered -30 to 30 for the edges in x and y planes:

And now we have a proper circle!

For interest, I dragged SUM(Sales) to Size and SUM(Profit) to Colour.

I wanted the tooltips to show the dateparts nicely (e.g. October instead of 10) and used DATENAME([p.Around the circle], [Order Date]) for this.

Then I just put it all together in a very simple dashboard and it’s done!

Of course, the value of this particular chart to convey information effectively is very questionable. I just wanted to see if I could build it.

Comments are closed.