Small Multiple Flows in Tableau

Small Multiple Flows live up to their name, combining small multiples and flow elements in a single viz. This allows us to combine a set of events, providing an intense data visualization about these events, while also connecting one event to the next via the flow element. This technique does need a viewer to invest some time into understanding the various pieces of the visual. There is a lot going on, thus it will definitely require effort and a little time on the viewer’s part (and why I put detailed legends on both visualizations).

I have included two Small Multiple Flow visualizations, built in Tableau, as part of this write up. Both are decently complex in terms of Tableau hacking as a result of leveraging the layering technique I previously posted about. The basic premise of layering remains the same, we make copies of our data and use each of them to use and then re-use an axis as many times as we need. Then we leverage sorting of the layer element to push backward/forward the visualization marks as we see fit (this is our pseudo z-index in Tableau). To get into the nitty gritty of these, please feel free to download and reverse engineer the workbooks from Tableau Public.  Herein I will provide some high level information around my approach and how I built (and layered) these two visualizations.

Viz 1: 2018 PGA Match Play

 

Why a Small Multiple Flow? 

We are able to visualize the hole by hole results for every match across the entire tournament, that is over 1.9k holes aggregated from more than 13k golf shots! Also we are able to use the combination of small multiple and flows together to follow a player throughout the tournament and see how they progress, how much, or little they won or lost their matches by and how far they ultimately went in the tournament. I did need to add some interactivity and highlighting to the viz in order to make following a golfer through the tournament a bit easier on the viewer. 

How?

The main element of this visualization is ultimately built on a single sheet in Tableau, it is made up of three layers within the sheet.  

The three layers of the visualization separated into columns (by moving "copy" on the columns shelf)

  • The first layer is the hole by hole result small multiple, with circles sized based on the player’s match status after each hole.
  • The second layer is the flow element that connects a players results from one match to the next. Here we are able to use color encoding to signify which player won the match and which didn’t.
  • The third layer is the labels on the left which allow the user to find (and highlight) a specific golfer throughout the tournament. 

Just like in the layering post, these are separated by the field “Copy” as shown in the pic above. Then for the dimension level and x/y coordinates we manage each layer separately with IF statements. 

Viz 2: 2018 NBA Playoffs

I did reach out to Adam McCann for design thoughts and feedback along the way on this one; thus wanted to say thanks to him for his time and thoughtful (and always helpful) feedback. 

Why a Small Multiple Flow? 

We are able to visualize every scoring play from every game of the NBA playoffs, as of this writing, that is over 8.7k plays across 85 games of basketball! As with the first example above, we are again able to use the combination of small multiple and flows together to follow a single team throughout the playoffs. We can see how the team won or lost their games (e.g., close game or blowout), how many games did the series take, whether they moved onto the next round and ultimately whether they won the title.

How?

As with the above, the main viz is built on a single sheet, using layering. This time we have 5 copies of the data as follows:

The five layers of the visualization separated into rows (by moving "copy" on the rows shelf)

  • The first layer is the scoring plays from all of the games in the playoffs.
  • Second is the flow element from one series to the next. This is color encoded to help the reader see who moved onto the next round.
  • Third is the circle background for each game, encoding how many games the team had won.
  • Fourth is the team legends to help follow a team through the viz.
  • Fifth is the flow from the legend on the left to the first round of games, this took a few tricks so needed its own layer. It is also color encoded to connect the legend to the first round.

Just like above, these are separated by the field “copy” as shown in the pic above. Then for the dimension level and x/y coordinates we manage each layer separately with IF statements. 

I do want to note that there are some other examples of Small Multiple Flows out there, here is one (amazing!) example that Adam pointed me to which was created by Giorgia Lupi. I hope you find some good use cases for this approach, if you do please share them as well.

Layering data for custom Tableau visualizations

This post outlines a method that has been shared before in the Tableau community. I was initially introduced to it by Noah Salvaterra’s Chord Diagram a while back. 

I am going to walk you through a layering technique, which allows use, and re-use of a single axis in Tableau. This can be done at different levels of granularity, different fields entirely or completely synchronized throughout, thus it can adapt pretty well to various use cases. Need to create a dual-axis in a single axis? This technique can enable this for us (as long as you need the same mark type that is). 

So What? With this technique you can build more detailed and very customized visualizations directly within Tableau (without the need for extensive data prep).

Two other quick call outs, one is the circle math I use here. I have adapted it from Joe Mako’s handoff map (a Tableau classic!). A quick aside, be sure to check out what Steve Wexler recently wrote about Joe and Kelly and their incredible impact on the Tableau community. The second is that I came up with the viz below only after seeing this work by Nadieh Bremer. The layout of my viz obviously mimics her layout based on a similar dataset.

By “layering” in this context I refer to building a number of separate visualizations and then overlaying them on top of one another. This is one reason why you can do so much in d3.js when it comes to custom data viz. There is really no limit to the number of layers and formats that you can stack together in the browser (just don’t load too many elements into the DOM). This technique in Tableau does have a few limitations of its own, for example, the number of marks you are rendering can grow to be quite large. Also, you are limited to only two mark types (e.g. lines and circles for example) in the viz you build.

Here is an example I built out using some data I gathered on the PBS Kids show Word Girl, the current (and VERY much) favorite of my 3 and 6 year old daughters. If you want to hear the theme song, un-mute your speakers or plug in your headphones. Also, I have to give Jonni Walker a shout out for some design help, especially in making the edges glow like Word Girl’s flight trail. Full disclosure, I did learn some new word definitions while working on this project.

You can also visit the interactive version on Tableau Public here

First thing we can take a look at is the deconstructed layers of the view. Here they are: 

You can see the parts of the viz are parsed on the value “Copy”. Just as Noah demonstrated in his post, I am doing a join with my data using a very simple file that looks like below: 

Now that we have layered (aka union'd) the data, we have what we need to do the same in our viz. There are just a few key steps to make this happen

Identify each layer using the field “Copy” (or whatever you called it). You can then set the level of detail of your viz with a simple if or case statement. Here is mine for the above example...

Now for each copy we can do whatever calculations we need at the different levels. My visualization is a multi-level circle, so for me, depending on the layer we are going to calculate either the inner, outer circle coordinates or the edges. With my different layers I am doing the following:

  • Plotting the villains in alphabetical order, clockwise from 12 o’clock, sized by appearance.
  • Drawing edges from villains to episodes they were in.
  • Plotting episodes (colored by season for the write up) clockwise from 12 o’clock. Note there are two copies of this, this is to allow for different tooltips based on interactions.
  • Plotting the vocabulary words of focus in each episode as pedals/satellites around each episode.

Here is an example of a single pill that based on copy does each of these above things.

I have similar equations on the y-axis which you can reverse engineer from the viz itself. With this technique, you can think of it as creating additional "Marks cards" for each layer of your data. Those cards are then accessible via the variable "Copy" and this can be used again and again; to draw marks, specify tooltips, specify labels, etc. 

Hope you find the technique helpful/useful as I did and let me know if you have any questions.

Bonus section: Calling the Oxford Dictionary API with Alteryx

Alteryx flow which pulls word definitions from https://developer.oxforddictionaries.com

The data I initially pulled from PBS Kids had a list of the vocabulary words each episode focused on. One thought I had was that I should really include the definitions for these 621 words (554 unique), that’s what Word Girl would do! So it was decided, question was how...

After a little research (aka a single Google search) I found the Oxford Dictionary API. Thanks to Alteryx I was able to then use this API in just a few hours. I was able to define 620 out of the 621 words I had from this process, so was more then happy with that result. This is what powered the definitions in the viz when you mouse over each word.

To do this in Alteryx we use the web download tool with our API credentials (app_key and app_id) declared as fields on the headers tab. I sent into this web download tool a list of my vocabulary words with api call URL (https://od-api.oxforddictionaries.com/api/v1/entries/en/) prepended to the word, a simple string concatenation formula. I did have to throttle the API call, and I output the resulting payload into a staged Alteryx database file so I was not repeatedly calling the API for the same data. 

From there I utilized the JSON parse tool, followed by a couple filter tools to pick out the specific key-value pairs of data I wanted, joined them back together and that was it. This data was ported into Tableau and used for the definitions in the tooltips when mousing over specific words. 

Bonus section 2: Changing parameters with URL Actions on Tableau Public

One of the effects that I wanted to achieve was some custom highlighting. I ended up implementing this via a parameter and some calculated fields across my different sheets Once that was all working, I had to implement a little trick in order to make this change available to the end user via a simple dashboard action (select action in this case). If you haven't read Jonathan's recent post on the subject, definitely check it out. What I ended up doing was using an URL action, pointing to the dashboard with a few specific additions and one trick that Rody Zakovich reminded me of (thanks Rody!). Here is the URL from my dashboard action: 

https://public.tableau.com/views/WordGirl/WordGirl?:showVizHome=no&:embed=y&:tabs=no&:linktarget=_self&Villains=<AGG(Dimension Villain Densified)>

From this URL, &:linktarget=_self tells Tableau to render the viz back into same container (e.g., not open up a new window). Secondly, I pass the new parameter value via &Villains=<AGG(Dimension Villain Densified)>

The last piece of this, in order for it to work in a single page on Tableau Public, was to create a blank dashboard, put a web page object onto the dashboard and point that web page to the "share" link of the actual dashboard with &:linktarget=_self appended to the URL. 

This is not necessarily perfect, as the whole dashboard is re-loaded on each action, vs just updating. However, it does work and keep the user on a single screen while interacting with the viz. 

More options for your Tableau Sankey Diagram

A quick look around Tableau Public can often lead you to a Sankey diagram at some point. I can only speak from my experience, but the majority of these visuals (including mine thus far) leverage the sigmoid function. This technique has been posted about and presented on (including by me) quite a few times across the Tableau community, I first found it on Jeff Shaffer’s Blog and this has of course morphed many times and ways, for example, some of the great work done by Olivier Catherin to build a Sankey leveraging polygons (also found on Jeff’s Blog).

Not so recently, Tableau came out with some improved dashboard spacing capabilities in version 10.4. I had been awaiting this feature for a while and could not wait to update some of my Tableau Public work in order to take advantage of it (granted it took me a while to do so). Now we can get rid of those annoying spaces which have been forced into our (tiled) visuals to date.

We can make this...

Look like this without having to float...

But as a result of this change, something became much more apparent, especially if you obsess over pixel perfection. Do you see it? How about if I zoom in a bit on the above picture...

Off just enough to drive you mad, isn’t it? I was brainstorming with Rody Zakovich about what the causes of this could be. We went through all of the various layout gotchas in Tableau, and came to the conclusion (his suggestion) that it has got to be the math. After a bit of investigation, I found that sure enough, it was the math. The sigmoid function math I was using served its purpose, but also ended slightly off from where it was supposed to. Instead of ending at 535, my curve is ending at 534.82 and so on. The result of this in my viz, is the imperfect pixel alignment which is now, much more obvious when these two sheets are truly bumped right up next to one another. So what now? We cannot stand for this pixel imperfection...

Well, what we can do now is morph this technique once again and change up the math used for plotting the curve. I took a shortcut here and adapted the math from D3’s easing functions which also have a great visual explanation by Mike Bostock here

Porting a selection of these easing functions (as not all are applicable) is an exercise in converting JavaScript formula syntax to Tableau formula syntax. The good news is that I went ahead did all that for you. You can just go ahead and copy the calculated fields into your own workbook as I demonstrate below. Here is a Tableau version of the visual explanation of the easing functions (less animation).

And here is how the calculated easing formula looks in Tableau. I decided to add two parameter toggles so you can easily switch between the formula and pick the resulting curve visual that you prefer for your viz.

Now, here are the steps you can follow to implement this technique in your own work. Note: This assumes you are leveraging densification and have an existing Sankey that you are modifying. For details on how to create a Sankey, check out Jeff's aforementioned posts.

  1. Save a copy of your work as we may break some things as we go.
  2. Download the example workbook below. This workbook is an example of a polygon Sankey, if you want a line Sankey workbook check here.
  3. Copy the fields and parameters listed here for the ease formulas needed and paste them into your workbook (select, copy and paste all of these at the same time):
    • Densification 
    • Densification (bin)
    • Densified PI
    • Index Ease
    • t
    • Easing
    • Easing Type (Parameter)
    • Curve Type (Parameter)
  4. If you were using sigmoid function before, you should be able to just replace the sigmoid function with these easing functions. Your formula probably looks like below:

    Start Position + (End Position - Start Position) * Sigmoid

    will need to be changed to

    Start Position + (End Position - Start Position) * Easing

  5. The last step is that you may need to adjust your table calculations, I start by replacing reference of your existing bin to "Densification (bin)". But be careful with that, as it could have a wider impact then you intended. From there it is just double checking your table calculations and their partitions. 

Here is the example workbook, change the two parameters to see the different options you will have with this technique. 

Talk to your Tableau Dashboard

Shouldn't an author be able to explain their Tableau Dashboard to every person who views it? Of course they should! This capability should be available to authors and accessible to their end users, regardless of the end user's abilities. We should also make Tableau's awesome interactive capabilities as accessible as we can as web users have vastly diverse abilities.

I encourage you to read through the detail below, however you can visit the working example here if you prefer to skip the write up. 

Background

A while ago Jeffrey Shaffer and I traded emails around his Tabitha post from 2016. We discussed the fact that in order to implement his technique, there was still a need to write some code, and that could end up being a barrier to entry for some. As usual, Jeff has done a great job of explaining what is needed in his post, but code still needs to be written to implement his technique. We noodled around some ideas of how we could enable the Tabitha project for those who did not want to write any code. This blog is the (hopefully) first step toward that effort, and thanks again to Jeff for the consults and inspiration along the way. I also reached out to Chris Toomey early on for some guidance in leveraging React for the project and how to structure things.

Also, thanks to Matt Francis and Adam McCann who let me use their vizzes for some of the built in examples. 

Approach

The approach is somewhat simple, we decided to build a JS API wrapper around our (or yours or any) Tableau viz which extends the end users mouse click UX to include voice recognition and response. This is centered on the Tableau JS API and getting as much information out of the workbook as we can once it is rendered (this also left me honestly wanting a good deal more out of the Tableau JS API). Lastly, I decided to build off the previous Tableau + React work I have done and leverage React for the build out of this “wrapper”. While I have used React, I am sure you could leverage other frameworks as well.

Implementation

The pieces leveraged for this project are as follows:

At a high level, the process followed in the code is:

Have Tabitha introduce itself and deactivate listening temporarily while speaking - With React, having Tabitha introduce itself was as easy as setting the initial state of the app with an introductory message and sending that to my responsive voice component. This could potentially be extended to the Tableau user via a Parameter as well.

Instantiate any Tableau viz submitted by an end user - This follows previous examples you have seen, nothing new here. I did push first interactive to state in my React app so that I could leverage that indicator in more than one component via props. Also, I leveraged the React life cycle to determine when a new viz URL has been provided and trigger the disposal of current viz and load of new viz in this situation.

Use JS API to pull all relevant information possible from the viz (based on JS API version at the time of this post) - This is a bunch of JS API calls triggered by first interactive, all of which store their result into an array. This is then referenced to validate voice recognition and also provide context in voice response. For example, this powers the information provided about the rendered viz back to user after the viz is loaded for the first time.

Start listening for voice commands and respond with confirmation or guidance if successful or unsuccessful request is received. - I honestly struggled for a while on this one. I was fighting the voice listener to turn it on and off based on whether responsive voice was speaking. It is currently working via a callback from responsive voice which toggles state and thus determines whether or not to take action on any phrase consumed. I ended up leaving the listener active at all times, but toggle whether or not to take action based on the aforementioned voice response call back.

Note: I decided not to paste a bunch of code into this blog, as this blog is more about use of the JS API wrapper and not actually having to write code (see below section). Having said that, all code is readily available on my Git, fork the repo and reverse engineer or better yet, extend the capabilities to your own needs. I would be thrilled to see some PRs roll through to help increase capabilities faster than I can get to on my own (which is pretty slow). I am always happy to answer any questions or provide more details on the code written for this project, so don’t hesitate to reach out if you have any.

Interacting with Tabitha

Here is how you can go about talking to your own Tableau viz...

  • Go to my page hosted on Github pages (same link is at bottom of this post) or fork your own copy to work with locally (instructions on how to get up and running locally are in the readme within the Git repo).
  • Put in your tableau public viz URL (use the share link, not the browser URL) and click the submit button... THAT IS IT!!
  • Feel free to take advantage of limited API via Tableau Parameters:
  • DESCRIPTION
    • Type: String, Any Value
    • Usage: include this parameter in your workbook and provide a brief description that you want Tabitha to read out to your user.
  • SELECT CONFIGURATION 
    • Type: String, List
    • Usage: include this parameter with Sheet-Field pair in Value-Display As parameter list respectively in order to enable mark selection from voice recognition. I took this approach to try and ensure that we don’t overload the browser, but that is still a possibility if you submit massive data to this config. Target a summarized sheet to be the most efficient with this. See examples of this in the example workbooks I embedded into the Tabitha app.
  • If Tabitha is not responding, check that the listening toggle button on the top left is in listening state, otherwise, click it to toggle it back into listening mode. Worst case, refresh the page and try again.
  • Just want to play around? Try the command “Tabitha Show Example” a few times.

Where can this go next?

  • This project is open source and available on my Git. It is not perfect (nor is it meant to be at this point). See something you don’t like? Please go ahead and try to address it and submit a PR. 
  • I did not do anything from a CSS perspective, so styling could be greatly improved.
  • I only tested this on Chrome on my MacBook, I doubt it will work in older browsers and/or phones.
  • Extend this to additional types of filters, allow multi selection, etc.
  • Improve lifecycle and async related activity between Tableau and Voice Response/Recognition as this can get tripped up sometimes (and then the computer talks to itself).
  • Augment the process to parse voice commands and enable less stringent commands to work well. For example, my daughter asked for two selections by saying “Tabitha select Anna and Elsa”, the current status of the project only selects the first, Anna in this case.

Lastly, click here to enjoy talking to your viz!

Easy as Pie React + D3 Chord Diagrams in Tableau

A functional example of Tableau integration with Nivo (React + D3) 

First things first...

Chris Toomey has done great work already in this space and I referenced his code and also asked him for help and input along the way. This write up builds upon his work and provides another integration technique and some additional capabilities within Tableau. Thanks for the guidance along the way Chris!

I am also leveraging code from Tamas Foldi and I’s earlier work on d3.js integration with Tableau, those posts are found here and here. He also helped me out with some of the interactive features in this example, so big thanks to Tamas for his help as well.

Second, the details...

Chris’ above referenced write up has a good intro of React for our purposes, definitely give his blog a read to get more information on that front. We are going to be integrating with and leveraging Nivo, which is self described by Raphaël Benitte (it's creator) as “supercharged React components to easily build dataviz apps, it's built on top of d3.” Nivo is one of many react component libraries that work on top of D3, each are different and bring their own features and focus to their projects. Here are a few more worth checking out (in no particular order):

I am going to assume you know how to leverage create-react-app and npm install to get up and running locally and import all the component libraries you will need. If you have not gone through this install process yet Chris’ blog walks you through some key steps you will need to complete, and Google is of course your best friend here. Here are the commands to run:

  • Create-react-app nivo_int
  • Cd nivo_int
  • Npm install tableau-api
  • Npm install nivo

That is it, if you run npm start at this point, your project will be bundled and rendered locally on your machine... Magic!

Once you have your local instance running, you should take a detailed look at how you want to structure your project and it’s components. This is really one of the key steps in the process and I would liken it to determining how you plan to layout your dashboard. For this effort we are going to create two components one to hold the tableau viz object and the other to house the embedded chord diagram within the Tableau dashboard itself.

Let’s do the easy stuff first and work on getting our viz to render on our page. Note: as Chris points out there is a npm package out there (tableau-react) that can make this very simple, but also is missing some of the api functionality. As such, I deferred to using Chris Toomey’s npm package tableau-api

With using create-react-app we are going to modify the src/app.js to write our code for getting our viz on the page. This can be done by importing our tableau-api library and then leveraging it as we would in plain old html/js. Here is how that looks...

So now we run npm start again (or if you left it running it will hot refresh thanks to webpack) and we should have our viz rendered on our page...

Now we have our viz, but it isn’t doing anything special ... yet. Next we are going to work on the component which we will be embedding within Tableau and integrating/leveraging the Nivo library. The bare minimum we can do here is pull the data out of Tableau (via JS API) and send it to Nivo in order to build our chart (on the fly). We are going to try to take a few steps beyond that for this example, including, exposing in Tableau, all of the props available from Nivo. This will allow us to customize the chord to our liking from directly within Tableau! No additional code required (see section 3 below on how to implement this yourself). 

Here are some of the key parts coded to allow for us to get these separate pieces to talk to each other.

In these two code snippets we see different aspects of how to get the two technologies to work together in order to accomplish our goal. Also, do not worry about re-writing any of the above code, you can easily access it on my git here. Click on the image below to view the interactive version on my GitHub. 

 This is a screen shot of the interactive example, click the image to visit the working version. Note: interactive version is working best on Chrome, but also functional in most current browsers.

This is a screen shot of the interactive example, click the image to visit the working version. Note: interactive version is working best on Chrome, but also functional in most current browsers.

Third, how to use this without writing code...

Here is a list of steps that you can take to use this without having to write any additional code. 

  • Grab my git repo
  • Change the viz url in src/app.js
  • In Tableau:
    • Add a webpage object to your dashboard
    • If you are copying this to your own git repo then your URL will be https://<username>.github.io/<repo>
    • Pass desired parameters via CHORD PARMS parameter in Tableau. Note this is optional and you can see an example of the format required in my example Tableau Public workbook. This must be well structured JSON and I have not built in any error checking into this process yet either. 
  • Enjoy your new d3 chord with zero additional code needed!

One other important item to note is that I have created four props that you can pass to make use of this technique. They are as follows (case sensitive and all values are strings): 

  • dataSheet - the name of the sheet in Tableau you want to use as the data source (must be on the dashboard that you have webpage object on as well). I would also try to keep your sheet names pretty simple (e.g., avoid special characters, etc.). Default is first sheet found on dashboard.
  • inField - 1 of 2 dimensions you will be using for the chord flow. Default is first field found on sheet. 
  • outField - 2 of 2 dimensions you will be using for the chord flow Default is second field found on sheet. 
  • valField - the measure that you will be representing in the chord diagram. Default is third field found on sheet. 

In addition to these four new props, you have direct access to all of the Nivo Chord Props via the process as well. 

Fourth, what next?

Here are some next steps that we can take forward on this in my opinion...

  • Complete a few more features into this example, like, enabling two-way interactivity between Tableau and React+D3 (only one-way is enabled at the time of this post).
  • Adapt JS API code to Tableau's new Extensions API structure
  • This same method could be used to render any of Nivo’s available chart types or other React + D3 packages for that matter. Additional, functional examples would help demonstrate this and would not take all that much time to put together. 

Updated on 12/4/2017

Additional example of Nivo integration, demonstrating the Stream component of Nivo working with Tableau.

 Example integration of Tableau with Nivo Stream component.&nbsp;THIS IS A SCREEN SHOT OF THE INTERACTIVE EXAMPLE, CLICK THE IMAGE TO VISIT THE WORKING VERSION.

Example integration of Tableau with Nivo Stream component. THIS IS A SCREEN SHOT OF THE INTERACTIVE EXAMPLE, CLICK THE IMAGE TO VISIT THE WORKING VERSION.

Visualizing MLB pitch location data with Alteryx + Tableau

This project started with some really interesting reading on the work done by brooks baseball (Dan Brooks and several others) and fastballs (by Mike Fast) sites. There are references to these sites throughout this post. 

Data gathering & preparation work

I used the Perl script from the fastballs - build a pitch db page to download the data from this MLBAM site. Then I leveraged Alteryx to parse the 2.47 million XML files (no, that is not a typo) over the 8 years I pulled data for. Here is a summary of files and their combined size by year.

Thankfully, tools like Alteryx and Tableau provide the ability to take work that would have taken me days and reduce it down to hours. It also allowed me to do a lot of this work while holding the newest Blicker, my newborn baby girl…

The best part is that it is a pretty simple Alteryx workflow within which I gained a new admiration for the directory and dynamic input tools. I know this has been done many times before, but here is my workflow which parses the XML files into a format more suitable for Tableau.

The workflow is:

  • Query the directory with the Directory Tool
  • Parse the path to obtain the different folders and files
  • Use Dynamic Input tool to import all of the files in each subfolder
  • Based on the type of file, differently configured XML parse tools are used in a synchronous manner.
  • Final data manipulations and output to text files for use in Tableau.

Visualization work

My goal was to visually investigate if pitchers and their pitch location have a defined “shape”, or if they all looked the same. Thus, I decided to go with a binned heat map to see if any shape came out of the location data. To create the binned heat map in Tableau, I binned both the Px [x] and Pz [y] coordinate fields to my desired aggregation level. I then manually adjusted (can you see me cringe as I type that?!?) the axes and size of the squares in order to achieve my desired look and feel. Lastly I added a small multiple layout and sorted/limited the data to the top 25 pitchers based on earned run average (ERA) for the year. You can reverse engineer all of this from the workbook embedded at the bottom of the post.

What I found is that most pitchers seem to have pretty consistent angled shape to their pitch location based on whether they throw left or right handed. This of course can differ slightly from one pitcher to the next. There are also some pitchers like Clayton Kershaw and Tim Lincecum (early 2010s) that had shape which was much less angled and thinner than then their same handed counterparts. Here are some examples of this.

Once the pitch location heat map was complete, I decided to supplement it with additional pitch data like speed and movement information (shown in the image above). I utilized a labeling trick that you might have seen before in order to add the pitcher’s names, numbers and various additional stats that you see above, it is not perfect, but worked well enough for this project. First we place the mark (dual axis with circles that are too small and transparent to see) and then we add a separate field with the text to be shown on the label.

I was not thrilled with text only for these additional data points, this limited my ability to easily place the pitcher within the population by scanning the detailed numbers across the small multiple. Thus, I set out to add a secondary layer of visuals, settling on the idea of an overlay of graphs when a specific pitcher is selected by the end user, here is how the overlay looks…

With this approach, I had to cope with the fact that I am covering up two of the five pitchers in each row upon selection. For that I came up with a little trick. Before I get into it, I will say that this method has some issues. Some of which are:

  • You are overlaying visuals on top of your page, you will not be able to leverage tooltips on the underlying viz.
  • I floated the visuals on top, thus sizing was required to be somewhat fixed so all the various dashboard objects where lined up well.
  • You have to create two copies of each overlay chart, this could cause additional maintenance.

That being said, I was reasonably happy with how the effect turned out, so here is how I did it. First thing first, create the base dashboard, then create an additional sheet for the first overlay. Make sure you are happy with this and it is complete, then duplicate the overlay sheet, naming one sheet … L and the other … R. Drag, place and size the sheets on top of your dashboard. Your view should look something like this.

Next we are going to create three simple calculated fields to trigger the effect. “Show L” and “Show R” are simply hardcoded values, these could be set to any value as long as they remain in sync with “Show Value”. “Show Value” is used to display either the right or left side depending on which column in the small multiple grid you are in. If the first 3 columns show the overlay on the right, otherwise show the overlay on the left.

Lastly, we are going to add three dashboard actions to implement the effect on our dashboard. Then, trigger and test that they are working correctly. 

  • We are going to highlight the selected pitcher so the overlaid chart is focused on the selected pitcher.
  • We add two action filters. One for left and the other for right. The are pretty much identical except one filters the left overlay using Show Value -> Show L and the other the right overlay using Show Value -> Show R.

Here is the result, I hope you like the viz and find some useful tricks within it as well. Since I was able to scale this with Alteryx, there are several other years on my public page as well. 

Note: I am just scratching the surface of this dataset and I look forward to digging in more and seeing what others do with it. Please note the license of the dataset if you do decide to download my workbook(s) and do some analysis of your own.

Dataviz Fun for #Datakids

As we all get ready for back to school (or are already back in school), whether it be Kindergarten or 8th grade its always fun to get vizzing and to get your kids involved!

Recently, the one and only Anya A’Hearn posted her inspiring quantified self project “Consumed”. My daughters are quite young, in the womb, 3 and almost 6. The thought I had was to have them build this type of viz with something they have way more of than they need. For us, an easy candidate for this was their (ridiculous) stuffed animal collection.

Since the kids are so young, having them document this in Excel and then create a Tableau viz wasn’t really going to happen (yet I made sure it did), so we embarked to create our dataviz on the floor of their room. First things first, we took all of the stuffed animals and tossed the into a one big pile…

One step that I missed at this point, was getting a guess from everybody on how many stuffed animals we actually had. Looking back at it now, I think we all would have grossly under estimated the number of animals we have. Oh well, something to remember for next time.

I didn’t really have much of a plan going forward at this point, but next we decided to split up the animals into different categories and make smaller piles for each category. I had the thought of breaking up the animals into the different types that we had, e.g., bears, people, etc. The girls were on board with this, but also overruled the appropriate category for some of their “specials”. This is why there is a bear in the monkey pile, a seal in the “pets” pile, a rainbow bunny in the people pile, another bear in the “Elmo” pile and so on.

At this point we decided to each make a guess at how many stuffed animals were in each pile. This part was pretty fun and we even got Mom involved on the guessing as well. The best part for me; watching my almost 6-year-old take the piles and put them into lines so that she could make more accurate guesses for our game and when my 3-year-old guessed “a lot” for one of the big piles.

Once we finished our guessing game, we made a big bar chart so that we could get actual counts for each of our categories.

And after the final tallies were in…

Our almost 6-year-old came in the big winner, only being one stuffed animal off of the total. The only thing left to do was for the kids to document our real life bar chart on paper (and apparently add some spirals, thanks Moana).

Lastly, it was time for Dad to translate that into Tableau, including matching colors and smiley faces in each bar. I tried to talk them out of this and explain visualization best practices, but, as you can see I was not successful.

I hope you find some fun items and concepts to viz at home as well and look forward to seeing your results!

Step lines and supported bars in Tableau

Step lines and supported bars in Tableau

Step Lines

I am a big fan of step lines (here is a good example from datasketch.es) so I was really excited to see that line type announced at last year’s Devs on Stage. While we wait for that feature to be provided directly within the product, we have two choices: (1) don’t use them, or (2) build them ourselves. Choice two is much more the DataBlick way, so I have tried to provide you with a few steps that you can follow to build this chart type yourself. You can also take a look at Tim Ngwena’s post here which details another method that you can look into for your use case.

Step lines are just lines at the end of the day. When I started looking into how to plot their points accordingly, the prep work reminded me quite a bit of the data prep needed for Jump Plot. We basically need to take our list of points and add an additional mark for each point, and potentially one at the origin (0,0) if that is desired for our viz (as it was in this case). I will be using step lines to help analyze the scoring to par across PGA tournaments this year.

Here is a small sample of the data we will be working with going forward, this is an aggregated data set, looking at the average score to par for pros on the PGA tour this year. We are going to plot “hole” on the x-axis and “Avg Score” on the y-axis to make our viz.

Read More

Weighted Medians for Weighted Data in Tableau

Weighted Medians for Weighted Data in Tableau

There are two ways weighted medians get talked about in Tableau: The first type of weighted median is the one we covered in our earlier Padawan Dojo: Weighted Averages and Weighted Medians post where we’re aggregating a data set and we want to make sure the median is computed over the underlying records. This post is about the second type of weighted median when the data itself has a weight, for example in survey data where each respondent has an assigned weight and we want to find the weighted median value of responses.

Read More

Padawan Dojo: Weighted Averages and Medians in Tableau

Padawan Dojo: Weighted Averages and Medians in Tableau

This is the first of two posts on weighted averages and medians, this one introduces a problem we've seen multiple times where reference lines aren't properly weighted. We need to use a different set of options in Tableau to get the desired results and are helped by an understanding of the different levels of detail that Tableau uses to aggregate measures.

Read More

To Animate or Not To Animate

To Animate or Not To Animate

Context

Previously I wrote this post around analyzing the predictions generated by 538 during March Madness each year. At the end of the post, I briefly discuss the possibility of telling the same story using animation in place of vertically scrolling through a static set of charts. I believe that, if used correctly, the ability to animate from one chart to the next can greatly assist the reader in understanding your analysis process. 

Read More

Building SVG Paths in Alteryx + Tableau

Building SVG Paths in Alteryx + Tableau

Background

Recently my family watched Disney’s Moana for the first time. We all really enjoyed the movie, especially my two young daughters. After the movie was over, my five-year-old noticed the spiral in the title on the movie case and asked me whether I could build it on the computer. I figured this was as good an opportunity as any to show her the power and possibilities of math. 

Read More

Analyzing 538's March Madness Win Probabilities with Alteryx and Tableau

Analyzing 538's March Madness Win Probabilities with Alteryx and Tableau

Story:

The concept for the story comes from visually comparing these two games (and several others like them). As I followed the early rounds of the 2017 tournament and tracked the games via 538’s predictions site, it seemed, more often then not that Men’s tournament games were closer then the Women’s.

Read More

Building towards d3.js “plugins” for Tableau

Building towards d3.js “plugins” for Tableau

This post is a follow up to my Vizception post from a few months back. We are still building off the technique described in detail within that effort. Here we will look at two additional implementations leveraging the capabilities available within d3.js (thank you Mike Bostock!).

The first of the two implementations looks at leveraging d3.js mapping projectionsTamas Foldi and I presented this example during a recent Think Data Thursday. Here we will leverage the referenced d3.js code and adapt it for use with our Tableau integration method. This will allow us to build choropleth maps in Tableau with access to the d3 projection library which provides just a few more options in addition to your standard Web Mercator (the Tableau default).

Read More

Telling a Story in Tableau

This short post is around trying to create an article like structure with in-line visualizations all within Tableau. Inspiration for this pulls from sites like 538 and polygraph as well as several authors from the Tableau Public community (like the one noted below, this recent VotD).

There have been many examples across the Tableau Public community showing the data storytelling capabilities of Tableau. These include leveraging additional JS libraries (via API/embed) like reveal.js (thank you Jeff Shaffer!), but others that caught my eye recently where examples of building out an entire story in a long form Tableau dashboard. Here is one example that Rob Radburn posted recently that got me thinking. Note: there are several others, this one by Rob is just a single recent example. 

I decided to see just how much work it is to do something like this, all within Tableau. The answer... not all that much. Like every tool, Tableau makes some hard things easy and some easy things hard. This type of visualization is a great example of the former and demonstrates the creativity that Tableau can empower it's Desktop users with. The viz story is just a simple collection of visualization sheets and text boxes, you can download the workbook to see how I went about laying out the story. The viz below is best viewed in landscape, hope you like it! 

Rose Curves in Tableau

Rose Curves in Tableau

I love when people get creative and come up with visuals like these, if you want to see more, check out Shirley Wu’s project with Nadieh Bremer at datasketch.es for starters. Techniques like these (or using things like the rose curve) to encode data will definitely require a more engaged user base. Readers will need to take some time to understand what each rose petal/shape is and then it will take them time to compare the petals across the visual. This type of technique is probably not the best choice to visualize your data when granular differences between your marks need to be analyzed by your reader.

Read More

#Data16 Twitter Network Project

#Data16 Twitter Network Project

For this year’s conference I undertook a project with Keith Helfrich to harvest tweets tagged with #data16.  We collected the tweets regularly throughout the week, and updated a view of high level summaries and detailed network visualizations.  This post details some of the highs and lows that we came across, and provides access to the workbook so you can do your own analysis and review as well. Please also be sure to check out Keith’s post on the same subject here.

Read More