I studied Trignometry several years ago. This knowledge came in handy when I wanted to draw circles using Tableau. I promise that I will do everything to make sure that you are not going in circles while following me on this journey.
Unlike my other blogs, the data prepping step for this use case won’t take more than a minute.
Add two data points 0 and 360 for X. You may use a spreadsheet to store the data. Alternatively, you could also paste the data directly in the data source tab of the Tableau desktop.
When you get to the worksheet, you only have one measure called X (user-defined). You may see things like “number of records” etc. They are Tableau provided.
First, create a BIN using the X measure. This is a key step. You getting a circle is very much dependent on this step, so, please pay close attention.
When you create the BIN, ensure that you are picking the values as follows:
The reason this BIN creation is so important because we need to create 360 values from the X values. Remember, we only have 2 values in X.
Drag the X(bin) to either column or row shelf and then turn on “Show missing values” before you do anything further.
Once the above two steps are completed, change the shape of our visualization to “line” from the “Marks card.”
To make sure that you followed the above critical steps, drag the X(Bin) from the dimension field to the row or column shelf once again. You should see a total of 360 values as follows:
Remove X(bin) from the row or column shelf.
Move the field, X(bin), from the “Details” card to the PATH card.
Create three calculated fields as follows:
- An index field. This will use the index() function that Tableau provides. This is for our visualization to follow 360 points. I will explain this in a moment.
2) COX-X field to draw the circle on X-axis.
3) SIN-Y field to draw the circle on Y-Axis.
Those who are not familiar with the trigonometric functions, a small section is dedicated at the end of this.
We have everything that we need for giving final touches.
Drag the SIN-Y field to Y-axis. Drag the COS-X field to X-Axis.
Select each field and change its scope from Table (Across) to X(Bin). This is to make Tableau to know to follow the 360-degree path!
If you have completed the steps as outlined, you will see the circle smiling back at you.
The above picture came from the “Math is Fun” web site. You will find the basic math needed for this blog from that web site.
https://www.mathsisfun.com/geometry/unit-circle.html