Toan Hoang

Drawing Election Circles

There have been a lot of requests to create this tutorial, especially with the upcoming elections, yep, I am starting to get excited about the election season. As such, here is our Tableau tutorial for creating an Election Circle Chart 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 into production.

Data

Download and load the following data into Tableau Desktop / Public.

Note: this data set was taken from the following repository: https://github.com/CivilServiceUSA/us-senate

Calculated Fields

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

Depth Parameter

Dimension Parameter

Distance from Center Parameter

Metric Parameter

Index

(INDEX()-1)

Age

DATEDIFF('year', [Date Of Birth], TODAY())

Distance

([Index]%[Depth Parameter])+[Distance from Center Parameter]

Number of Items

{FIXED : COUNTD([Name]) }

Multiplier

180/(MAX([Number of Items])/[Depth Parameter]-1)

Item

IF ([Index]%[Depth]) < [Depth]/2 THEN
    ROUND([Index]/[Depth],0)
ELSE
    ROUND([Index]/[Depth],0)-1
END
* [Multiplier]

Years in Office

DATEDIFF('year', [Entered Office], TODAY())

Size

IF [Metric Parameter] = "age" THEN
    [Age]
ELSE
    [Years in Office]
END

Color

If [Dimension Parameter] = "party" THEN
    [Party]
ELSE
    [Gender]
END

X

COS(RADIANS([Item]))*[Distance]

Y

SIN(RADIANS([Item]))*[Distance]

So now that we have created a lot of Calculated fields, we will now put this together into a Worksheet.

Worksheet

We will now build our worksheet:

If all goes well, you should see the following:

Have a little fun and explore the various parameters to see what happens. Now we will adjust the cosmetics:

You should now see the following:

and boom we are done, this technique can be applied to various scenarios beyond an election circle. You can find my version of this visualisation on Tableau Public at
https://public.tableau.com/profile/toan.hoang#!/vizhome/ElectionCircle/ElectionCircle

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:

Exit mobile version