#ReViz – LGBT | Gay rights by state

This week whilst searching for inspiration for the Tableau Iron Viz competition I came across this unbelievably beautiful and informative visualisation from The Guardian US Interactive Team. I love it.

If you were to ask me where I would put this viz on the ‘Functional Beautiful quadrant‘ it would be very close to being in the top  right.

This viz type is also one that features on the front cover of ‘Information is Beautiful’, a book with which I have gained all sorts of insight on the subject of data visualisation and ideas for my work.

For this chart type you need two dimensions and a measure. In the case of this ReViz our first dimension is our states, these are our segments, our second dimension is our law type, represented by the different rings around the circle.

You could almost treat these as rows and columns.


Our measure is represented by the level at which the laws exist; the measure is represented by the colour of each sector.



Remembering that we are working with a circle chart type and polygons, completing the data preparation in Alteryx consisted of a number of similar practices to those learnt in my previous #ReViz project so I will only point out the differences and how to adjust the formulas to account for this.

Difference number 1:

In contrast to our ‘coxcomb’ chart where we are dealing with sectors (or a slice of pie), this time we are dealing with a ‘donut segment’.




Difference number 2:

Our radius is not determined by the measure value but instead the dimension ‘row’ that it is on. Our first set of points, from 1-5 on diagram c will have a radius of lets say 1, our 2nd set of points for that segment, 6-10 will have a radius of lets say 2.

The segment that would lie above this, the first set of points would have a radius of 2. The 2nd set 3, and the points are offset in this way.

So how do these differences affect the formulas introduced in the previous #ReViz blog. Lets start with our angle formula that we can use to identify the angle at each point.

This is the formula we used last week, with our first and last points representing our central points and therefore; whilst the path points between represented our angles at the points on the edge of the circle.

IF [PathID] = 1 or [PathID] = 13 then 0 else ((360/[Number of Segments])*([SegmentID]-1))+ (([PathID]-2)*(360/[Number of Segments])/10) endif

Instead this time we need to find the angle of our lower row first, path points 1-5 (diagram c), before then finding the angle for path points 6-10.

A quick point. We know that points 5 and 6 have the same angle, as do 4 and 7, 3 and 8, 2 and 9 and 1 and 10.

We also have this same fields available, where ‘[number of segments]’ is the number of dimensions, in our case 51 states; [Segment ID], an individual ID for each of these segments, from 1-51; and finally a [Path ID], in the case of our example 1-10. Although In my viz I used 40 points to ensure a smooth curve.

Here is the formula that I used to generate the angles at each Path ID.

IF [Path ID] <= 5 then

(([Segment ID]-1)*((360/[Number of Segments])))


((((360/[Number of Segments]))/4)*[Path ID])-(((360/[Number of Segments]))/4)


(([Segment ID]-1)*((360/[Number of Segments])))


((((360/[Number of Segments]))/4)*(10-[Path ID]))


So what is this actually doing?

So our first condition IF [Path ID] <= 5. Here I am segregating our 1st half of path points to our second, as mentioned above the calculation will need to be different.

With this part of the formula (([Segment ID]-1)*((360/[Number of Segments]))) I am outlining the initial angle for that segment. Dividing 360 by the total number of segments will return the angle covered by each segment. Multiplying this by our [Segment ID]-1 will therefore give us our start point. Segment 1 will start at 0 degrees. Segment 2 will start at 1 * the angle for each segment, segment 3 will be two times this value and so on.

The following aspect of the formula will return the angle increment from the original starting angle for that segment.

((((360/[Number of States]))/4) returns the angle increment between each path. Multiplying this by the Path ID gives us the increment value from the original angle for the segment. -1 from our Path ID ensures that we do not increment at the point of our first Path, and therefore it remains at the original angle. This is similar to what we do above with our segments.

(((360/[Number of States]))/4)*([Path ID]-1)

Okay, so this is our value when the points are less than or equal to 5. The next part of the formula focusses on where this condition is false; i.e. points 6-10 when our angle returns back on its self.

The only difference is in the 2nd part of the formula.

((((360/[Number of States]))/4)*((11-[Path ID])-1))

The part (11-[Path ID]) gives us the inverse of what our Path ID value should actually be, so as highlighted above, when my Path ID = 6 I will get the angle for the same as I would for the first part of the formula for Path ID 5 (remembering basic maths that 11-6 = 5).


Now that we have the angle for each of our points It is now a case of how do we offset the radius and therefor the location of our x,y points as highlight in the difference 2 section

Well I have ID’d my 2nd dimension (rows) in a similar way to that of my segments. So we can use a formula and this value to create our offset. Remembering that we must convert our angle to radians in order to calculate our x,y points.

Again I will need to condition my formula based on the Path ID. If it is less than 5 I want a lower radius value than if it above 5, thus giving us our offset.

The value for X can be calculated as:

IF [Path ID] <= 5

then sin([Radians])*([Row ID]+2)


sin([Radians])*([Row ID]+3)


Why +2 and +3 I here you ask, well the difference between these 2 values (2 v 3) gives us the offset between the points below or above 5.

Starting at +2 gives our lowest Row ID (1) a value of 3. This part determines the size of the hole in the centre of our target chart. If we wanted we could make our starting value -1 and therefore our calculation will start at 0 and thus our chart would start from the centre (where the radius is 0).



Our value of Y can be calculated in the same manner, swapping Sin for Cos.

IF [Path ID] <= 5

then cos([Radians])*([Row ID]+2)

else cos([Radians])*([Row ID]+3)



With this visualisations there are a lot of actions which I plan to outlined in a separate Tableau tips blog.

I hope you enjoyed the read. The finished workflow is available here.

Here is a link the the final visualisation.




One thought on “#ReViz – LGBT | Gay rights by state

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s