Hi all,

Once you’ve built one curved chart you’ve built them all. Bit of a brash statement you may think… but kind of true at the same time, especially in terms of logic. I think what may be particularly confusing in the community is everyone has their own unique way of building a chart with curves and the requirements of data densification.

For me, I build all circular and chord style charts in the same way every time. The only thing that may differ is having dynamic start and end points.

Today we will look to go through how to create a simple fan chord chart. It combines a bunch of knowledge from previous like this one but also includes elements taken from the work of Brian Moore, like his bezier work.

Big shout out to Brian. Really this approach only differs in having dynamic start and end points. If you want to hardcode your values, it is well worth taking a look at Brian’s tutorial. In fact the data we use is a reduced version of his.

We’ll look to cover off all four of these charts in the tutorial in some capacity, but a focus on creating the far left hand chart. But of course I must start with the disclaimer of: Please consider when you might want to use this. Then consider it again. and a third time just for good measure.

So a couple of things for context when building stuff with radials and points along a curve.

• You’ll need a start and an end point (both x and y points) These can be hardcoded into your dataset or they can be flexible. Ours will be flexible today as we will write the calculations for the circle. We will also make our start points flexible.

• Often quite confusingly you will need to join in a bunch of points (in this case 50) to plot as dots in between your start and end point. These points will then be adjusted (random maths equations) to give it the curvature of the path we want to follow.

Here’s what we will look to create:

So if we look at the template data from the repo at the top and the workbook. We have 30 points of data (which will end up being 30 chords outwards) and then just a category which we will use to show some adjustments.

The points tab, contains 50 records of data, this is needed to densify the data ie. create 50 points between the start and end co-ordinates along a curved path.

What we then do is join the data with a custom 1=1 relationship. Our total dataset therefore will be 30*50 = 1500 records.

Now we are ready. You’ll notice I don’t have any start or end co-ordinates. This can be quite daunting.

For now lets create two calculations for a static start point.

Lets create

001. Start X

-1

and lets create

001. Start Y

0

we’ll come back and play with these points a little later, but for now all our chords will come from a static position.

Now we need to take a look at creating some end points & for this we will need to know the fundamentals behind building a circle. Again, I always follow the same process:

• Rank the number of points I will need

• Find the angle between each of the given points, i.e the spacing amount between each point

• Then actually shift each point based on the spacing

• Finally use some trigonometry to make it into a circle

So here goes:

002. Rank

[Line ID]

This is just anything that can order our values.

then

003. Angle

360/{MAX([Line ID])+1}

This is a way of saying a full circle is 360 degrees so find the max value of all the records we will have. I.e 30 records in the data.

004. Rank Angle

[002. Rank]*[003. Angle]/2

Now, given we have ranked all our marks and then found what the angle would be between each of them we multiply them together to be able to find the specific location of each mark. The division by two is because we want our end points to be a semi circle not a full circle!

005. Sin

Just some standard trig

005. Cos

More trig!

I then convert these values into 006. End X and 006. End Y

End X is our cosine calculation, End Y is our sin calculation

It’s a bit of a useless step but I felt like if you wanted to cross reference this blog with Brian’s it helps to understand where we are up to.

If we plot this on a chart this is how it looks:

Now we have two pieces to the puzzle ticked off. We have some start points that are static, and we have some end points. Now we just need to find the chord along it.

Next we look to put in some placeholders for X Mid and Y Mid.

007. X Mid

0

007. Y Mid

0

Again, we can revisit these at the end, but these are the mid points our curves veer towards before reaching the final end point.

T

([Points]-1)/{MAX([Points])-1}

The T calculations finds all the points proportional between 0 and 1.

Finally, we can create the chord calculations that take into account our start and end points.

008. Bezier X

((1-[T])^2[001. Start Y]+ 2(1-[T])[T][007. X Mid]+[T]^2*[006. End X])

and

008. Bezier Y

((1-[T])^2[001. Start X]+ 2(1-[T])[T][007. Y Mid]+[T]^2*[006. End Y])

We can follow this step up to create some end points (dots), so where our T is 1 ie the maximum mark along the chord, then plot a dot.

010. Circles

IF [T] = 1 then [008. Bezier_X] END

Time to build.

• Drag 008 Bezier Y onto Columns and 008 Bezier X onto Rows. Make them both dimensions.

• Add Line Name to detail

• Add Points onto path and make a dimension.

• Next add 010. Circles onto rows, dual axis and synchronise.

• You may need to remove the multiple fields off colour when synchronising.

And there we have our fan chart.

Now we can go back and revisit some of our calculations.

Going Further

• Making Y Mid 0.5 instead of 0. see how it moves the mid point making the chords fan later.

• Try moving the Start X & Y values. Notice the flexibility in these calculations.

• Why not change the Start Y based on category. You can have different sections with different start points.

• By playing around with the start and mid points you can make all 4 of the original chart types.

Have fun!

The template can be downloaded on Tableau Public, using the link at the top of the page.

LOGGING OFF,
CJ