How to create a Semi Coxcomb Chart and Coxcomb chart in Tableau.
I saw the pic in Google and was really inspired to build this in Tableau.
I knew that this is a semi coxcomb chart. I went and had a chat with Ken Flerlage and Kevin Flerlage about it. Ken Flerlage said, I shall tag him and paste the same pic in the forums and he will try in the weekend while Kevin Flerlage asked whether I had referred to tutorials, I said no. Later, I decided to build this on my own in Tableau.
I used the coxcomb workbook by Ruth Amarteifio Thanks to Ruth Amarteifio from Information Lab for showing how to build a coxcomb chart in Tableau. I downloaded the workbook and looked how did she do it and later, making changes and little learning from blogs on Tableau, I was finally able to build the visualization.
I basically posted this visualization which I created in Tableau on Twitter and asked whether if you have a use case for it. Some liked it, some asked for how did I create it. So, I am basically showing you how I created this amazing Semi Coxcomb chart in Tableau.
Step 1: We need a simple dataset consisting of a Dimension and Measure.
Technology , Respondents (in %)
Robot Process Automation, 0.29
Artificial Intelligence , 0.2
Blockchain , 0.11
Machine Learning , 0.1
Cloud Computing , 0.08
Reinforcement Learning , 0.06
Natural Language Processing , 0.05
Cognitive Computing , 0.04
Deep Learning , 0.04
Optical Character Recognition ,0.02
Internet of Things , 0.01
I created this sample dataset for this chart. Save it as an Excel file or a csv file.
Step 2: Getting the data into Tableau.
Open Tableau Desktop or Tableau Public (Whatever you are using). Connect to your data source. After connecting, from the Sheets panel, drag the Sheet on top of the Sheet to Union the Data.
If all goes well, you will have the following,
We will need Table Name Column. We will hide the Sheet Column. So Right click on the Sheet column -> Select Hide. The Sheet column would now be hidden. You will be left with this.
Step 3: Creating Calculated Fields and Bins
We would need some calculated fields for building this chart.
1 Category index
//Numbers each category in the Data
index()
1 Increment Index
//numbers each of the increments in the Pad in each segment
index()
1 Segment Index
//numbers each of the segments in the circle
index()
2 # Increments
102
2 # Segments
WINDOW_MAX([1 Category Index])
//The number of categories
3 Segment Angle
//Segment position multiplied by degrees per segment. Segment no.1 starts at 0 degrees etc
([1 Segment index]-1)*(PI() /WINDOW_MAX([1 Segment index])).
Here, we are using PI() as it is Semi Coxcomb Chart, which means that it is a semi-circle representation of Coxcomb Chart. In Geometry, you might know Pi value is 180 degrees and semi-circle also measures 180 degrees. That is the logic of PI() here. We will also need PI() for further calculated fields.
4 Radius
//The circle’s area will be the metric’s value for the category in question
SQRT (AVG([Respondents (in %)]) /PI())
Pad
IIF([Table Name] =’Sheet1',1,102)
Here, we use the Table Name column which was created while the Sheet Union. It says, if there exist a table with name ‘Sheet1’, then value assigned to it will be 1, else value assigned will be 102. You will have 2 values for this column, ‘Sheet1’, and ‘Sheet11’. So, for ‘Sheet1’, value assigned will be 1 and ‘Sheet11’, it will be 102 respectively. To view, Click on the ‘Data Source’ below and can view the calculation.
Here is calculation
X
IIF([1 Increment Index]=1 OR [1 Increment Index]=WINDOW_MAX([1 Increment Index]),0,
WINDOW_MAX([4 Radius])
* COS([3 Segment Angle]+
((([1 Increment Index]-2)*WINDOW_MAX(PI())/([2 # Segments]*[2 # Increments])))))
Y
IIF([1 Increment Index]=1 OR [1 Increment Index]=WINDOW_MAX([1 Increment Index]),0,
WINDOW_MAX([4 Radius])
* SIN([3 Segment Angle]+
((([1 Increment Index]-2)*WINDOW_MAX(PI())/([2 # Segments]*100)))))
Now, we will create bins. Right click on Pad calculated field -> Create -> Bins. Give an appropriate name to the bin. Select Bin Size as 1. Click Ok.
Step 4: Building the Semi Coxcomb Chart
Now, we will build the visualization. Change the Mark type to Polygon.
Drag Pad (bin) to the Columns shelf. Right click and make sure that ‘Show Missing Values’ is checked. Make sure that Pad (bin) is Discrete. Then, bring Pad (bin) to the Path shelf.
Drag X to Columns Shelf and Y to Rows Shelf. Make X and Y continuous. Drag Technology to Color Shelf. If you did all correctly, you should have the following.
The chart is not seen because, we need to do editing, i.e. Editing Table Calculations.
Right click on X. Select Edit Table Calculations.
In Nested Calculations , Select X. In Compute Using, Select Specific Dimensions and check only Pad (bin) keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 1 Increment Index. In Compute Using, Select Specific Dimensions and check only Pad (bin) keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 3 Segment Angle. In Compute Using, Select Specific Dimensions and check only Technology keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 1 Segment Index. In Compute Using, Select Specific Dimensions and check only Technology keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 2 # Segments. In Compute Using, Select Specific Dimensions and check both Pad (bin) and Technology keeping Pad (bin) on the top. Select At the level as Deepest , Restarting every as None and Sort Order as Specific Dimensions.
In Nested Calculations, Select 1 Category Index. In Compute Using, Select Specific Dimensions and check only Technology keeping it on the top. Select Sort Order as Specific Dimensions.
Right click on Y. Select Edit Table Calculations.
In Nested Calculations, Select Y. In Compute Using, Select Specific Dimensions and check only Pad (bin) keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 1 Increment Index. In Compute Using, Select Specific Dimensions and check only Pad (bin) keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 3 Segment Angle. In Compute Using, Select Specific Dimensions and check only Technology keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 1 Segment Index. In Compute Using, Select Specific Dimensions and check only Technology keeping it on the top. Select Sort Order as Specific Dimensions.
In Nested Calculations, Select 2 # Segments. In Compute Using, Select Specific Dimensions and check both Pad (bin) and Technology keeping Pad (bin) on the top. Select At the level as Deepest , Restarting every as None and Sort Order as Specific Dimensions.
In Nested Calculations, Select 1 Category Index. In Compute Using, Select Specific Dimensions and check only Technology keeping it on the top. Select Sort Order as Specific Dimensions.
If all goes well, you will get the following
Then Right click on ‘Technology’ in Color Shelf -> Sort. Select Sort By as Field. On Sort Order, choose Ascending and in Field Name, choose Respondents (in %) and in Aggregation, keep it as Sum only.
You should get the following.
Now change the Default Number Properties of Respondents (in %) as Percentage. Drag Respondents (in %) in Tooltip Shelf.
Now a bit of Formatting,
Click on small arrow dropdown at right side of X and Y. Uncheck ‘Include in Tooltip’ and ‘Show Headers’. Also Uncheck ‘Include in Tooltip’ on Pad (bin).
Remove Grid-Lines, Zero-Lines, Axis Rulers and Axis Ticks.
Remove Column and Row Dividers.
Format the Tooltips.
After Formatting, you should get the following
You can also great a Bar chart and use Highlight Action to Highlight the Data.
And yes, we are done with our visualization. I recently, used this chart in my visualization titled, “Respond to Change”
You can view the workbook on Tableau Public here.
If you change the PI() to 2*PI() then it will become a coxcomb chart as shown below
Also, you find this workbook on Tableau Public here.
Lastly, if you are creating this chart and using it in your project, please do tag me so that I can see it. You can connect with me on LinkedIn , Twitter and Tableau Public.
Thanks for Reading
Vignesh Suresh.