Last week, I was playing around with bar chart variations and created Curved Bar Charts and thought I would also try to create Triangle Bar Charts as well. As noted in the previous article, this is for variation, fun, and does have a cool look to it; however, use very carefully. So with that said, I hope you enjoy this quick Tableau Tutorial.

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

Load the following data into Tableau Desktop / Tableau Public.

Country,Value
United States,60
United Kingdom,70
India,50
Australia,60
France,30

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

Path
1
3

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 two records for each Country as we are going to be drawing lines and using densification to get more points on our canvas. For more information, check out our article on Data Densification.

Calculated Fields

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

Create a Distance Parameter

  • Set Name as Distance.
  • Set Data type to Integer.
  • Set Current value to 10.
  • Click Ok.

Create a Size Parameter

  • Set Name as Size.
  • Set Data type to Integer.
  • Set Current value to 10.
  • Click Ok.

Create 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()

TC_Value

WINDOW_MAX(MAX([Value]))

TC_Country Rank

RANK_UNIQUE([TC_Value])

X

IF [Index] = 1 THEN
    [Index]-[Size]
ELSEIF [Index] = 3 THEN
    [Index]+[Size]
ELSE
    [Index]
END
+([TC_Country Rank]*[Distance])

Y

IF [Index] = 2 THEN
    [TC_Value]
ELSE
    0
END

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

Worksheet

We will now build our first worksheet:

  • Change the Mark Type to Polygon.
  • Drag Path (bin) onto Columns.
    • Right-click on this object and ensure that Show Missing Values is checked.
    • Drag this object onto the Path Mark.
  • Drag Country onto the Colour Mark.
  • Drag Country onto Columns.
  • Drag Index onto Columns.
    • Right-click on this object, go to Compute Using and select Path (bin).
  • Drag Y onto Rows.
    • Right-click on this object, go to Compute Using and select Path (bin).

If all goes well, you should have the following:

So we are almost there, let us adjust the cosmetics:

  • Hide the Y-Axis Header.
  • Hide the Index Header.
  • Hide the Zero Lines.
  • Hide Grid Lines.
  • Hide the Row Dividers.
  • Hide the Column Dividers.
  • Edit the Tooltip.
  • Add Labels.

If all goes well you should end up with the following Triangle Bar Chart.

Alas, we are not finished quite yet and will no create a variation to this by creating Triangle Overlapping Bar Charts.

Triangle Overlapping Bar Charts

Note: use this version with extreme caution. I would go as far as say use this for fun only.

Create a new Worksheet:

  • Change the Mark Type to Polygon.
  • Drag Path (bin) onto Columns.
    • Right-click on this object and ensure that Show Missing Values is checked.
    • Drag this object onto the Path Mark.
  • Drag Country onto the Colour Mark.
  • Drag X onto Columns.
    • Right-click on this object, go to Compute Using and select Path (bin).
    • Right-click on this object, go to Edit Table Calculations…
      • In Nest Calculations select TC_Country Rank, select Specific Dimensions and ensure that only Country is checked.
  • Drag Y onto Rows.
    • Right-click on this object, go to Compute Using and select Path (bin).
  • Right-click on the Distance Parameter and select Show Parameter Control.
  • Right-click on the Size Parameter and select Show Parameter Control.

Adjust the cosmetics in the same way as before (and add a little transparency), and if all goes well you should see the following:

Try adjusting the Size and Distance parameter and see what you can come up with. and now, we are done, you can find my data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/TriangleBarCharts/TriangleBarCharts

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 Visualisation, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic.

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:

Also, do be sure to check out our various courses:

4 COMMENTS

  1. As you said we need 2 records for each country right. For example if i have the data in a table and inorder to get the 2 records for each count can i union the same table. so, that i can get 2 records of each rows. Also while dng union i can add the field of path as 1 for one set of the query and for other 3 .
    hope this should work. Let me know if anything can be changed

Leave a Reply

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