Updated: Jan 14, 2019
What I will cover:
1. A couple easy data investigation views to set you on the path to picking the right viz.
2. Parameter Controlled metric selector
3. How to build a bump chart.
4. How to build a panel chart.
5. Applying viz-in-toolip
One of my favorite things about #MakeoverMonday is the diverse data sets and myriad of creative approaches to displaying them across the Tableau Community; that also makes it very difficult to avoid seeing a hundred examples on Twitter and Tableau Public when trying to figure out what viz to pick. My best advice is to stick to looking at the data first (not Twitter, Public, Reddit, or even my Bruins pocket schedule…)
What is in this data set?
Team, season (date), number of home and away games, home and away attendance totals, then a rank by home attendance total.
The first thing that comes to mind is “That rank is weird.”
The seating capacity and surrounding population density could have significant impact on home attendance. If we had the data showing away attendance total as a % of the total seating capacity for each game played on the road, perhaps we could see who had the widest spread fan base, but I don’t want to be hunting the schedules and attendance for every single NHL game over the last 18 years. An easier complimentary data set to acquire is the rink name and seating capacity for each NHL team.
What I wanted to know, is what teams pack their barn every single night, what teams have the biggest road draw, and how much do cup wins impact these rates.
Back to the data.
I spent a few minutes on Wiki and found this list of all NHL rinks and their capacity. https://en.wikipedia.org/wiki/List_of_National_Hockey_League_arenas . After making sure I had a good alignment of team, arena, and capacity by year, it is time to jump into Tableau. If I throw the seating capacity for each rink onto a number table, it looks close.
If I hold down ctrl and drag the text pill to size after switching the mark type to bar, I can quickly create a no-axis bar chart.
This is much easier to analyze for me. What is data is saying to me is that these is not much difference between rink sizes across the NHL, about 20% variance between the biggest and smallest rinks.
Another good way to investigate a data set like this is with a quick highlight table. Drag seasons onto columns and teams onto rows with the total home attendance as the text value and color. The lock out in 04-05, the strike shortened 2012-13, and the expansion addition of the Vegas Golden Knights immediately stick out here.
While some may like to forget work stoppages in professional sports, I want to included them in this viz. As a hockey fan myself, I cannot ignore the entire 2004-05 and half of the 2012-13 seasons taken from the fans due to labor disputes. I might have to format around Vegas’s recent arrival but strikes and lockouts are important to consider in the final views.
At a close look, the Havs row looks consistently dark, and I can also see the Blackhawks recent resurgence. However, trending data for a group is best represented from left to right and using a vertical axis or size element for each record. Line charts are an easy one;
Now the work stoppages really stick out, but my goal was to find out what home venues have the best attendance % and what teams have the best road draws. Given that the records have a relatively tight range of values, I am going to go with a bump chart. Bump charts show ranks in a combination line and shape chart that allows the end user quickly see the entire league, and interact with the viz to highlight specific teams. Here is one of my favorites from Zen Master Matt Chambers https://www.sirvizalot.com/2018/11/how-to-create-expanding-bump-charts.html.
Time to viz;
First thing I want to build are some calculations to allow the end user to select between four different ranked metrics: home attendance, road attendance, home attendance sell out %, and total attendance. This will be controlled by a parameter.
Create a parameter using a LIST of STRING values.
We will get back to that parameter shortly.
Next, I want to build out the rank calculations for the different metrics. Rather than memorizing all of the table calculation and aggregation syntax, I try to let Tableau do the work whenever and possible. Once I get one, I can copy, paste, and edit the rest. Using the value I already had populations (sum(home attendance)) use the following settings.
Now I can click on the measure pill to locate the “Edit in Shelf” option which allows me to copy out the calculation.
Then just copy, paste into a new calculation, and be sure to rename the field and change the default table calculation settings to the TEAM level as the default will look across the entire table and give a unique rank for the team’s season performance, not compared to other teams in the same season.
Repeat this process for the road and total attendance ranks.
The most interesting metric to me is the sell out %. This is created by dividing the home attendance by the seating capacity for each arena multiplied by the total number of games played. I did that work in the data in excel for this example, but a nest table calculation could accomplish the same thing.
Once I have that bit, I can make another rank calculation which is the final one for this viz.
Next is to create a calculated field that references the user selected metric to display the correct rank. For this, use a CASE statement. This simply means that you are telling Tableau that in the CASE of the parameter section, WHEN is it X give me y.
So now, just replace the current value in the line chart with the newly created Select Metric Calc field, then hold cntrl while dragging the measure pill in the row shelf to create a dual axis chart.
Gorgeous right?! OK so this is a giant mess, but we are only a few steps away from the final view! Now if only I had every single NHL team logo in a shape file someplace… Luckily my #datafam is always there to help out (Thanks again @MarkBradbourne).
It was at this point that I finally cracked and looked at some other #MakeoverMonday submissions, starting with Mark Brabourne’s, and wouldn’t you know it, there are quite a few bump charts and interactive pieces using the logos.
I should just quit now right? If the idea is not original and there is no chance for #TableauPublic glory, why even bother? Not at all! Discovering these other vizzes really helped validate my approach to this data set. While I did not set out to make a bump chart, the fact that so many other people did the same must mean I am on the right track. Rather than getting discouraged looking at the stunning works of amazing data artists like Mark, I feel energized and inspired!
There are plenty of resources out there for adding in custom shapes to Tableau. I wont go into detail in this blog, but here is Tableau’s help articles on the topic. https://www.tableau.com/drive/custom-shapes
So now I have the shapes, removed the distracting colors from the lines and am ready to create the dual axis chart. Right click on the axis of the shape chart and select Dual Axis. Just click on the axis to the right to make the following changes.
1. Select dual axis
2. Synchronize axes
3. Then hide the axis to the right so that there is only one list of ranks being displayed to the right.
Behold the beauty of the bump chart!
Creating the interactive logo’s in the header require building a panel chart. My favorite resource for custom chart types like this is usually Coach Kreibel’s #TableauTipTuesday series, a treasure trove of succinctly presented how-to Tableau videos and examples. https://www.youtube.com/watch?v=kKxRJVBYIZc
Start by creating a simple shape chart with the team logos.
You need three things to create a panel chart: a column divider calculation, and row divider calculation, and the proper table calc setup.
Row Divider: int((index()-1)/(round(sqrt(size()))))
Column Divider: (index()-1)%(round(SQRT((size()))))
So what are these two calcs actually doing? They are both using the index function to count the number of rows (teams) and column position in the data. Then, by getting a rounded figure of the square root for the size, Tableau can best fit the shapes into the most even number of rows and columns no matter what the final dimensions of the view are on the dashboard. With 31 teams this won’t fit perfectly with the same number of shapes in each row and column, but it will look much cleaner and make the logo’s much easier to see and interact with.
Drag each of these new fields to the row and column shelf, drag teams from the row shelf to detail, then be sure to set the values to be discrete and edit the table calculations so that they COMPUTE USING TEAM.
The next step is to add a sort. These shapes will default to a data source sort, so if I drag in the calculation being used to select the metrics, then apply it to the team sort, the shapes will automatically change order when the metrics are manipulated. Lastly, I need to add in the line-shape dual axis chart with the actual metric values and Cup indicators into the tool tip. Click on tool tip, remove the current contents, then add in the sheet name.
I would like a clean line chart and another hockey shape. THE NHL HOCKEY SHAPE… One more quick search on Wiki and I had each Lord Stanley’s Cup winners from each year in the data and was ready to assemble the rest of this dashboard. For this, just make a line chart using the Select Metric Actual Value, hold control while dragging the measure pill to the right in the rows shelf, and change the mark type from line to shape. Drag “Cup Winners (the field I added which says “Won the Cup! For the correct team/season and “Eny” for the rest. I added in another custom shape for a Stanley Cup outline. https://en.wikipedia.org/wiki/List_of_Stanley_Cup_champions
Click on one of the axes to make the following changes.
1. Select dual axis
2. synchronize axes
3. then hide the axis to the right so that there is only one list of ranks being displayed to the right.
4. Now you have a dual axis line / shape chart.
Before we put the final layout together, I had another idea. What if we could also show the actual values along with the ranks? This is what viz in tool tip was made for!
First step of this process is to make sure the actual values interact with the metric parameter, which offers the end user a single metric control for all views. This is another copy/paste/edit job from the previous Select Metric Calc.
Swap out the Ranked measures for the original values, along with an aggregation edit. In this case, the numbers from the original data need to be wrapped in a sum function to total them. If you forget to do this part, you will get a mix error.
It is a little crowded, but this chart is going inside the tool tip of our logo-panel chart, so the final view will be filtered to just one team at a time.
Now that the views are constructed, time to lay them out on the final dashboard. A prominent title is a must. They do not always have to be at the top, but that is where most viewers will expect to see it. The interactivity of this chart is my focus, so the panel chart and parameter control should also be towards the top. This gives me a nice big section below to display the bump chart, which I know will take up a considerable amount of space.
After making some sizing changes to the shapes, citing my data and image sources so Andy Kreibel does not swim across the Atlantic to scold me, and throwing in vertically aligned text box to call out the 2004-05 lockout, I am going to add in two actions. A hover-highlight action to let the user focus on a single franchise, and a select-highlight so the user can select a group of teams to compare. Click on Dashboard in the top tool bar, select actions, then use the following configurations:
From raw data to a beautiful interactive bump chart in less than 90 minutes! https://public.tableau.com/views/TheNHLsBestBarns/TheNHLsBestBarnsandm?:embed=y&:display_count=yes
Was this blog helpful?
Please leave comments or questions below and I will be sure to respond!