How to - Modified trellis

This is a tip coming off of my recent IronViz submission in which I created a "Wall of Presidents" using a single sheet without any data prep (Cheers to Adam Crahen of TheDataDuo.com for recommending me to do it in a single sheet).

The Goal.

Create a modified "Trellis" chart using Images and Circles in a staggered position to recreate a search I did on Google. Image below

  

The idea

When looking at the images, I particularly liked the Walls where a President was highlighted in the Middle. I thought this would work well in Tableau because a user could interact with the viz and choose which President the wanted to "Highlight". Once I realized what I wanted to do, it was all about figuring out how to do it with my data.

The data

When exploring the dataset I found, I noticed there was a column with the label "Position". This was a simple numeric field that just listed the numerical order of the president. Originally I thought I was going to have to use INDEX() to create the wall, but given I already had an ordered field, I didn't have to introduce complexity with Table Calcs. With this "Position" field, I knew I could use calcs and modified trellis calcs to create my wall.

The method

Step 1 was identifying the exact shape I wanted. After exploring similar images online, I decided the ideal wall would follow a 12X5 matrix, in which rows 2 and 3 would have a gap in the middle 4 images + 4  blank spaces + 4 images, and with the last 4 Presidents being split on either side of the wall. This would allow me to put a floating image in the Middle that I could use Dashboard actions on to swap in and out.

In order to create this matrix, I knew I had to adjust the "Position" field to create the gaps in Rows 2 and 3 (The blank spaces). So, off to calcs I went.



When thinking through how I would do this, I knew I needed to offset the Position in such a way that I could create a Trellis calc on it to fit the sheet. The first two lines offsets Rows 2 and 3 so that there would be a Gap in the middle of the wall (This is where my floating sheet would go later). The next step was the offset the last 2 presidents to the end of the wall. Notice this follows a 4, 8, 16 pattern.

Once I create the calc, I put it on the Columns shelf as a Continuous Dimension show I can test that my gaps are proper

 

Notice how the gaps are equally spaced, and the first group is the same as the third, and the last two are spaced out 8 to the right. This is exactly what I needed to proceed onto the next calcs

Step 2 was creating the X Axis part of the Trellis. To do this, I used a Math to make my AdjustedPosition Calc line up in Columns of 12 (This works because off my offsets)


X Axis
([adjustedPosition] - 1) % 12

Here I use a calc similar to the ones we use in Trellis charts where we use the Modulo operator. We subtract 1 to ensure the 12, 24, 36, etc is not placed in the first column. Notice the Number of Records in each column is balanced on both sides.

Step 3 was created the first Y Axis for my Presidents images.


Y Axis Pics
FLOOR(([adjustedPosition]-1) / 12) * 2

Couple things to note on this. The first step is Diving by adjustedPositon calc by 12, this gives me my initial rows for each position (Still need to subtract 1 following the same logic as the X Axis). The next step is the to take the FLOOR of it so that I have single Integer for each Position.

The next thing you might notice is the I multiplied the Calc by 2, this was done because I knew I wanted to add a Dual Axis to "Stagger" images and circles with the Presidents relative positions. By multiplying by 2, I knew I could offset each row by 1.

Next, I simply reversed the Y Axis, changed the mark type to Shape, and assigned each position to the images



 Step 4 followed the same method as step 3, but slightly different. Knowing that I wanted a staggered setup with images and a circle shape, I offset the Y Axis Pics calcs to by 0,2,4,6,8. So in order to Dual Axis this into a staggered shape, I needed Rows on 1,3,5,7,9. To do this, I used the same calc as before, but added 1 at the end

Y Axis Dots
((FLOOR(([adjustedPosition]-1) / 12)) * 2) + 1

As before, I reversed the Y Axis. Notice how the Rows are now offset the Pics calcs by 1.

Step 5 was dual axis and sync.


After this point, it was just about formatting and cleanup. I removed grid lines, and added fields to the detail shelf for Dashboard Actions.

Once I had this shape it was just about putting it on a Dashboard, and floating another sheet in the "Gap" space I created. From there I added charts below that could highlight presidents based on categories.

To learn more, download the viz below and check it out!

All feedback and suggestions are welcome.


Thanks for reading! Rody
Previous
Next Post »
0 Comment