Getting Animated Part 2 – Basic Bar Charts In Tableau
In the first blog in this short series I covered the impact of Tableau’s new animation feature on basic line charts. You can read that here. In this post, I’m going to cover some of the basics of bar charts and how they will be affected by filtering in Tableau.
Again, there are all manner of advanced ways to play with bar chart animations in Tableau (bar chart races, for example) but I want to focus on the more regular sorts of experience that a Tableau user will have, and will look at filtering and sorting.
So just like the last one, this post will explore the two different types of filters and the way the affect our viz in Tableau. Let’s start with the non-slicing filters – remember, these are the ones that are already in our view, the dimensions used in our bar chart structure. In the example below I’ve got three of them, the category (which is also used to determine the colour), the sub-category and then in the columns there are segments.
Even with just the non-slicing filters there are a lot of things going on there. Let’s step through them:
- filtering out/in a category or subcategory – as we lose a category, the other categories move and fill up the space. In my example I’ve also set the fit to ‘Entire View’, so the heights of the bars have also increased in order to fill out the space. But the lengths of the bars and the x-axis are unchanged. If I had not set the fit to ‘Entire View’ then the bar width would have been retained, but we would have introduced some additional white space.
- filtering out/in a segment – as we lose a segment from the columns, the other segments move and fill up the space. Now in this example nothing is changing on the vertical and the bar heights are remaining the same. But because the view size is fixed the relative size of each column increases. This means that the bars get longer. The font on the x-axis labels do not change, however, and if my labelling is set to automatic rather than fixed then in some cases the tick mark intervals may change, just as they do here.
Now let’s consider the other filters. To recap from the previous blogpost, slicing filters are those which change dimensions that are not in the view, but whose components make up the measures. For example, there are four years of sales in the view, but YEAR([Order Date]) is not used in the columns or rows as a dimension. But we could filter on it. If we deselect 2016 then we would be taking that ‘slice’ out of the sales numbers. The example below uses that year filter and also one other to demonstrate how slicing filters animate our bar charts.
So, what’s going on here? Well, when we deselect the year 2016 the lengths of the coloured bars reduce to show only the value of the sales in the years from 2017-2019. And if we only select a subset of the Ship Modes the same happens.
At this stage I need to fess up that what you’re seeing is not the default behaviour. That’s because I have fixed the x-axis ranges. This can be done in one of two ways, either by manually editing the axis and setting the range to fixed, or by introducing a dual axis with another set of bars beneath the coloured ones that are not affected by the filtering. That’s what I’ve done here, and that’s why you see the grey portions (slices) of the bars that have been deselected. I’ll cover that method in a later post, but for now be assured that I’ve done this primarily for the purpose of demonstration to help understand the concept.
Manual sorting is that achieved by dragging and dropping a dimension around the view. Here are a few examples of that within the existing view, with each of the dimensions that are within the view – note that in this case the bars are simply trading places, and moving smoothly from position to position.
For computed sorting (driven by selecting the sort icon, or switching a parameter that’s used within a rank calculation), everything will shuffle in unison. For example:
What is more noticeable in this case is that the headers for the sub-categories moved instantly while the bars transitioned to their destination. This isn’t anything you can control while the labels are in the header, sadly. I’m sure it’s in the development queue, however.
Combining Slicing Filters and Sorts
To finish this blog, let’s look at how the filtering features and the sorting feature can be used together, prompting the bars not only to animate in length when they are sliced, but also to change rank.
I’ve deliberately tried to steer clear of anything particularly complex at this stage. There are a few other things within the user experience that also affect the animation. Things like adjusting the layout of your window, or changing the size of the header, which will adjust the dimensions of the bars. Additionally, use of the pages shelf and hidden calculated fields driven by parameters can be used to generate an animated transition. This should give you a clearer idea of the fundamental concepts when animating bar charts in Tableau, however.
I intend to follow this up with a simple overview of what dashboard interactivity will look like in dashboards featuring mark animations, and possibly an exploration of scatterplot animations. Watch this space!