I was experimenting with possible ways of adding labels onto Polygon based data visualisations and think I might have something. With that said, do enjoy our latest tutorial on creating Petal (Polygon) Diagrams in Tableau.

Note: This is an alternative type of data visualisation, and sometimes pushed for by clients. Please always look at best practices for data visualisations before deploying this into production.

Data

We will start by loading the Sample Superstore data into Tableau Desktop / Tableau Public.

Note: If you have Tableau Desktop, you can use the Sample data source, but if you are using Tableau Public, download and load the following data source.

Once your data is loaded into Tableau, right-click on the data source and click on Edit Data Source… with the Data Source Editor open, paste the following:

Path
0
360

Note: If you are using Tableau 2020.2 or great i.e. have access to new Relationship Model, you will need to double-click on the originally pasted data source to open up before pasting in the Path Data.

You should get an error as there is no joining column, however, click on Add new join clause, go to Create Join Calculation, type 1 and click OK. Do this for the right-hand side as well. Ensure that you have Inner join selected and you should see the following:

Note: we need additional records as we are going to be drawing lines and using a model to add more points on our canvas.

Calculated Fields

With our data set loaded into Tableau, we are going to create the following Calculated Fields and Bins:

Path (bin)

  • Right-click on Path, go to Create and select Bins…
  • In the Edit Bins dialogue window:
    • Set New field name to Path (bin)
    • Set Size of bins to 1
    • Click Ok

Index

INDEX()-1

Region Index

INDEX()

TC_Sales

WINDOW_SUM(SUM([Sales]))/2

TC_Size

IF [Index] = 45 THEN
    1
ELSE
    0
END

TC_Text Label

IF [Index] = 45 THEN
    [TC_Sales]
ELSE
    0
END

Shape (X-Value)

SIN(RADIANS([Index]))+1

Shape (Y-Value)

IF 180 <= [Index] AND [Index]<=270 THEN
    -1
ELSE
    COS(RADIANS([Index]))
END+1

X

IF [Region Index] = 1 OR [Region Index] = 2 THEN
    1    
ELSE
    -1
END*[Shape (X-Value)]*[TC_Sales]

Y

IF [Region Index] = 1 OR [Region Index] = 4 THEN
    1    
ELSE
    -1
END*[Shape (Y-Value)]*[TC_Sales]

With this done, let us start creating our data visualisation.

Worksheet

We will now build our worksheet:

  • Change the Mark Type to Polygon
  • Drag Order Date onto the Filter Shelf and filter to 2018
  • Drag Region onto the Color Mark
  • Drag Path (bin) onto the Columns Shelf
    • Right-click on this pill and ensure that Show Missing Values is selected
    • Drag this pill onto the Path Mark
  • Drag X onto the Columns Shelf
    • Right-click on this pill, go to Compute Using and select Path (bin)
    • Right-click on this pill and select Edit Table Calculations.
      • In the Nested Calculation select Region Index
      • In Compute Using select Specific Dimensions and only select Region
  • Drag Y onto the Rows Shelf
    • Right-click on this pill, go to Compute Using and select Path (bin)
    • Right-click on this pill and select Edit Table Calculations.
      • In the Nested Calculation select Region Index
      • In Compute Using select Specific Dimensions and only select Region

If all goes well, you should now see the following:

We will now add out outline:

  • Ctrl (or Command) Drag and Drop the X pill to the right to duplicate
    • Right-click on this pill and select Dual Axis; right-click on the Axis Header and select Synchronize Axis
  • In the X (2) Marks Panel
    • Change the Mark Type to Line
    • Drag TC_Size onto the Size Mark
      • Right-click on this pill, go to Compute Using and select Path (bin)
    • Drag TC_Text Label onto the Label Mark
      • Right-click on this pill, go to Compute Using and select Path (bin)
    • Click on the Label Mark
      • Check Show Mark Labels
      • Set Marks to Label to Min/Max
      • Set Scope to Line/Pie
      • In Options check Allow labels to overlap other marks and Label maximum value

You should now see the following:

We will now adjust the cosmetics and have the following:

  • Hide the Grid Lines
  • Hide the Zero Lines
  • Hide the Axis Headers
  • Format the TC_Text Label to currency and align to Center
  • Adjust the Size

You will want to keep formatting until you have something like the following:

and boom, we are done! I hope you enjoyed creating this data visualization and learned some cool techniques as well. As always, you can find this data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/PetalPolygonDiagrams/PetalPolygonsDiagram

Summary

I hope you all enjoyed this article as much as I enjoyed writing it and as always do share the love. Do let me know if you experienced any issues recreating this Visualization, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic. Do also remember to tag me in your work if you use this tutorial.

If you like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy: https://www.patreon.com/tableaumagic

8 COMMENTS

  1. Great great explanation. I just finished the tutorial and I cannot believe I was able to follow your instructions step by step. Little by little I am understanding what you are doing with each calculated step and that helps me plenty.

    Thanks!

  2. Hi Magician, great tutorial once again! I wanted to do this to all countries in my dataset set out in a single worksheet, how would I go about doing this?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.