

Tableau Animation Core Concepts
source link: https://datavis.blog/2020/08/14/tableau-animation-core-concepts/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Why Animate?
Animation enables us to make use of the preattentive attribute of motion to better understand changes between states, such as when filtering or sorting in a visualisation. This post will focus more on how animation works in Tableau. For more details on why animation can be a good idea and examples of use cases, take a look at my earlier blog post.
What is a Mark in Tableau?
I’ll be using the term mark ID throughout this post, so before I introduce that concept, I want to briefly cover what a mark is for completeness. A mark is how Tableau encodes data in the view. This could be with circles, bars, lines, shapes, polygons etc.
The number of marks in the view is not dependent on the number of rows in your data. One million rows could be represented by a single mark, for example a text mark that shows the total sum of sales. Conversely, just three rows of data could be represented by 3 marks, for example the sum of sales by customer, where each mark represents a different customer ID.
View Level of Detail
It’s also useful to introduce here the concept of the level of detail of the view, or view LOD. The number of marks in the view is dependent on the view LOD and the view LOD is determined by the dimensions that are added to specific parts of the view highlighted below:

The Tableau help pages discuss this in more detail here.
In the below example, I’ve added Category to the Label shelf, which has created three circle marks as there are a total of three Categories in the data source. So each mark (each circle) represents one category and the view LOD is at the granularity of Category.

Below, I’ve now added Segment to both the Label shelf and the Colour shelf. This changes the view LOD to now be at the granularity of Category and Segment, meaning there will be a mark for every unique combination of Category and Segment in the data. The data source has at least one row of data for every combination, meaning there are 3 (Categories) x 3 (Segments) = 9 marks in the view:

Note that adding Segment to multiple shelves (Label and Colour) does not affect the view LOD differently than if I had only added it to just one shelf. It just means that Segment is encoded in the view in two different ways: once by colour and once by labelling.
Mark IDs for Animation
With that background, we can now introduce mark IDs. A mark ID is a unique reference for a single mark in the view and is determined by the dimensions in the view. Measures are not included in the mark ID.
In that sense, they are similar to the view LOD, however, mark IDs refer not the dimension name, such as Category or Segment, but instead to specific instances of them, such as “Furniture” and “Corporate”, and each mark ID is effectively the unique combination of these dimension values that identify a mark in the view.
I say ‘effectively’ for two reasons. Firstly, the actual mark ID used behind the scenes in Tableau will be some encoding of these dimension values and not necessarily the literal values we see on the screen here, however, these labels we see are a useful way to talk about mark IDs.
Secondly, not every dimension in the view will always be used in the mark ID when using the Pages shelf, but more on that shortly.
Mark IDs are important for animation as they determine whether or not a smooth transition of a mark will take place between two states of a view, such as before a filter is applied and after it is applied.
Let’s take a look at a simple example. In this visualisation, the view LOD is at Category and Ship Mode. I have those two dimensions on both the Colour and Label shelves so you can see the (effective) mark ID of each mark.

If I now change the Year filter to 2019 (image below), you can see that: two mark IDs are still present as they exist in both years; two have disappeared as they have no sales in 2019; and one new mark (and corresponding mark ID) is shown, “Technology-Standard Class”, for which there were sales in 2019 but not in 2018:

The table below shows what happens to each mark ID (and its corresponding mark) as the filter changes from 2018 to 2019:

Here are those transitions animating in the view:

Using the Pages Shelf to Animate
The prior example used the filter shelf to change the state, from Year filtered to 2018 to Year filtered to 2019, which triggers animation to take place. This is a valid use case when animating from one state to another with some user interaction (changing the filter).
If you want to show animation over multiple changing states with a single user interaction, however, such as showing transitions across multiple years, you need to use the Pages shelf as this allows you to sequentially transition through all unique values within a dimension.
Let’s animate this sample data:

The following example shows a single mark in the view, representing Tables in the North region, animating across the 5 years shown in the data, above:

Notice that, even though there are 3 dimensions in the view: Year, Region and Item, and the Year dimension is changing between each state, the mark still animates seamlessly (without fading out/in) across all years.
This is because Tableau is automatically removing the Year dimension from the mark ID to leave Region and Item only, so the mark IDs remain the same across all years, allowing seamless animation.
This makes sense because, if Tableau didn’t remove the Pages dimension, when you moved through the Pages, the Page value would change every time, so the mark IDs would always be changing and therefore nothing would animate.
Not all Shelves are Equal
As mentioned earlier, not every dimension value will necessarily be included in a mark ID. As we’ve just seen, dimensions on the Pages shelf are not included in the mark ID.
Secondly, when you are using the Pages shelf, it’s possible that dimensions on shelves other than Detail may not be included in the mark ID. This is easier to illustrate with an example so let’s animate this sample data, which is the same as the data used earlier except for the highlighted cell:

To start, I will just add Region to the Label shelf and Year to the Pages shelf. When we get to 2018, the mark fades out (exits the view) and a new mark fades in (enters the view) because we have a change in mark ID from “North” to “Central”. Remember, the Year is not included in the mark ID as it’s on the Pages shelf, which is excluded from mark IDs.

Next, I will also add the Item dimension to the Label shelf. You might think that this would change the mark IDs to be as follows:
YearMark ID2016North-Tables2017North-Tables2018North-Central2019North-Tables2020North-Tables
And therefore expect that the mark would again exit as we reach 2018 and a new mark enter the view, however, that is not the case. This time the mark transitions seamlessly through all years:

It may be that you would rather have the mark exit and enter the view in this case, as the labelling indicates that the entity is changing from Tables in the Central Region, to Tables in the North Region. If that is the case, you can easily override this behaviour as we’ll see in the next section.
Force Inclusion in the Mark ID
It’s possible to force Tableau to again include Region in the mark ID by adding it to the Detail shelf as I have done below. This time we get the same effect as the first animation with the marks exiting and entering the view:

The takeaway here is that if you’re using the Pages shelf along with multiple other dimensions in the view and are not seeing the type of animation you expect, try moving (or copying) those dimensions to Detail.
Default Versus Custom Animation
Hopefully the above introduction to the core concepts of how animations are created in Tableau helps in understanding how Tableau enables a variety of default animations without any additional effort on our part, such as when changing Pages (as we’ve already seen) and, for example, when sorting and filtering as shown below:

It is possible, however, using parameters and calculations, to achieve more advanced styles of animation, as the following sections will demonstrate.
Creating Custom Animations
What follows are examples of animations you might want to build for specific use cases along with notes on how to create them. As always, there’s generally more than one way to create something in Tableau, so adapt or improve the approaches used here as required.
Changing the Date Part
This first one is fairly simple. A parameter can be used to set the date part, which is then used in a date calculation and placed on the Column shelf:

Below is the calculation and parameter configuration. Note, the values in the parameter start with lowercase letters but are displayed with an uppercase letter at the start. This is because the DATETRUNC calculation requires the date part argument to be all lowercase.

The one thing to note here is that the Animation style needs to be Simultaneous for the best animation effect.

Switch from Sequential to Parallel Years
This is the final result we’re looking for:

This is trickier than it seems. When I was first exploring animations in the beta, I tried building this using a calculation that shifted all the dates back to 2009 when the parallel option was chosen:

However, this doesn’t work as, because the dates (dimensions) are changing, the mark IDs also change, therefore – except for 2009 where the dates don’t change – we don’t see the desired animation. Instead the later years first fade out (exit the view) and then fade in (enter the view) at their new positions:

To make the animation work, the dimensions (Year and Month of Sales Date) need to be added to the view but instead of putting them on Rows and Columns, they are placed on the Detail shelf, which ensures they will be included in the mark IDs but means they don’t need to change their values to update how the view is rendered. Instead, to change how the view is rendered, a calculation based on the dates and the parameter is created that is then placed on the Columns shelf:

When the p.Sequentially boolean parameter is set to True, the number of months from Jan 2009 to the month of the sales date is returned and 1 is then added at the end of the calculation. This results in 1 to 12 for 2009, 13 to 24 for 2010 and so on.
When the p.Sequentially boolean parameter is set to False, the number of months from the first month in each year to the month of the Sales Date is returned (and 1 later added). This results in 1 to 12 for 2009, 1 to 12 for 2010, 1 to 12 for 2011 and so on, which results in the years appearing in parallel in the view.
Having the Month([Sales Date]) on Detail ensures a separate mark is drawn for each month. Having Year([Sales Date]) on Detail ensures that the lines for each year are not connected between years.
Below is the full view configuration:

Animating Between Different View LODs
Another scenario is changing which dimensions are used to set the view LOD and animating between these. For example, if our data contains Sales at a monthly granularity, we might want to animate between the below view LODs:
- Year and Month
- Month only (i.e. No split by Year or Category)
- Category and Month
The same rules apply. We can’t just swap the dimension used in the view LOD by changing a parameter, as that will change the mark IDs and therefore the desired animation won’t occur. There will still be animation, but it will be marks entering and exiting the view and not marks moving between positions, as shown below:

Again, all dimensions required to represent the different view LODs are added to the view and then a calculation is created that calculates sales at the desired level of granularity based on the parameter selection. This gives the effect of changing the view LOD despite it actually remaining constant at the level of Year, Month and Category.
The calculation uses a Level of Detail function to exclude either one or two dimensions to result in a Sales figure as if the view LOD had changed:

Overlapping Marks
It may seem confusing to state that the view LOD doesn’t actually change as we switch between the 3 different views in the previous example, especially when we go from multiple lines to a single line. Surely that means the number of marks is increasing and decreasing, doesn’t it?
It appears that way, but in fact the number of marks remains constant. What is happening is that marks are being overlaid on top of one another. For example, if I select what looks like one mark in the view below, I’m actually selecting 6 marks – one mark for each Category in this case. You can also see that the total sales value of those 6 marks is £6.6B, whereas the axis shows the value at £1.1B (which is 6.6B / 6):

Exploding Scatter Plots
The next example is similar to one I used some time ago in this visualisation from early 2020, inspired by Hans Rosling’s TED talk, which allows you to change the level of detail of the circles in a scatter plot from countries to regions.
Again, all dimensions required for the different view LODs are added to the view (Country and State in this example) and an LOD calculations is used to exclude one dimension to create the more aggregated view. Below are the two calculations used on Rows and Columns.


Below is the resulting animation:

Animating Headers
In the current release (2020.3), headers to not animate. However, it’s relatively easy to create a workaround for this by following the below steps:
- Create a view with the headers
- Create a second view with your marks (e.g. bars) with headers hidden
- Tile them in a container on a dashboard
- Ensure any filters and sorting is applied to both views!
Be careful with number four as, if both sheets don’t have the same settings, the headers won’t align to the corresponding bars.
Below is a simple example of headers animating along with bars. Please see the related workbook for this blog post to see the details of how this (and all other examples above) was created:

Summary
While creating more advanced types of animations does require some additional work, as described above, the good news is that the majority of animation, used for filtering, sorting and paging, for example, is achieved by simply switching on animations. Nothing more. See my prior post for more examples of these along with details of the Sequential and Simultaneous styles of animation that can be used.
Finally, I just want to say thank you to Paul Isaacs at Tableau who has been generous with his time in answering my questions and providing feedback on this material.
Technical Notes and Reference Materials
Sometimes Animations Don’t Play
Tableau can render a visualisation either locally on the client device or on the Tableau Server. For less complex views, client side rendering is faster and is the default option. However, if a visualisation goes over a defined level of complexity (based on the number of marks in the view and various other factors) it will be rendered on Tableau Server.
Animations will only play if the rendering takes place on the client device. So if your visualisation in very complex, it might not animate. If you have access to the Server, you can change the threshold of complexity that is used as the deciding factor for switching from client side to server side rendering. Read more about that here.
Features that Don’t Animate
As of version 2020.2, the following features do not animate:
- Maps and density marks in web browsers
- Pie, polygon, and text marks
- Axes and headers (though see the workaround earlier in this post)
- Forecasts, trends, and reference lines
Source: Tableau Help
Note also that the use of polygons or the page history feature in a visualisation will also force server side rendering and therefore disable animation.
Blog Posts on Animation
Mark Edwards has written a series of posts on animation, the first of which is here: http://pointsofviz.com/getting-animated-with-tableaus-new-feature-part-1-line-charts/
Liam Spencer has written a detailed post on “Complex Animations” here: https://wilhelmsbrick.com/tableau-animations/
Alex Varmalov‘s blog post on animating Streamgraphs in Tableau:
http://coolbluedata.com/?p=1075
My earlier blog post introducing animated transitions in Tableau
https://datavis.blog/2020/01/21/tableau-animated-transitions/
Examples of Animation on Tableau Public
My workbook containing all the examples used in this blog post:
Tableau Animation Workbook
Alex Varlamov – morphing between chart types:
https://public.tableau.com/profile/alexandervar#!/vizhome/Gaming_Market_in_Motion_Anim/Games
Klaus Schulte – morphing between chart types (on mobile):
https://public.tableau.com/profile/klaus.schulte#!/vizhome/TheIschglSpread-ironviz2020/TheIschglSpread-ironviz2020
Liam Spencer – Storytelling with animations. See Liam’s blog above for details on how this was made:
https://public.tableau.com/profile/liam2029#!/vizhome/CommonMentalDisorder-MakeoverMondaywk27/Dashboard1
Search Twitter or Tableau Public for the hashtag #VizAnimations for many more examples.
Tableau Conference Videos
Data Stories and Animation – by Jock Mackinlay
Tableau in Motion | Tableau’s new Viz Animations – by Paul Isaacs
and Phil Naranjo
Help Pages
Format Animations
https://help.tableau.com/v2020.1/pro/desktop/en-us/formatting_animations.htm
Level of Detail
https://help.tableau.com/v2020.1/pro/desktop/en-us/datafields_typesandroles.htm#DimLOD
Marc Reid
Twitter | Linked In | Tableau Public
Recommend
-
8
Core Functional Programming Concepts December 1, 2016 If you’re a developer like me, then you probably grew up learning about Object-Oriented Programming and how that whole paradigm works. You may have m...
-
10
HTTP/3 From A To Z: Core Concepts (Part 1) ...
-
4
C++ Concepts and the Core Guidelines Sandor Dargo 11 hours ago2021-10-13T00:00:00+02:00Let’s get back to C++ concepts and have a look at the rules and best practices that the
-
8
Mar 13 2022 Core cloud computing concepts you should be aware of Like every technology, cloud computing also a good number of terms that you should be aware about while learning. These terms could come quite handy and ca...
-
10
React 18 sets the foundation for concurrent rendering APIs that future React features will be built on top of. This release focuses on performance improvements and updating the rendering engine. Quick Guide Cate...
-
4
24 Hypnotic 3D Animation Concepts by Webshocker Meet a new creative name in D4U Gallery: this time, for the regular dose of some artistic inspiration and motion a...
-
4
02. Learn Core ConceptsSeptember 2, 2022 · 9 min readNitya NarasimhanSenior Cloud Advocate, Illustrator
-
6
@hummusonrailsBen GreenbergDevRel @ Parity TechnologiesReceive Stories from @hummusonrails
-
3
-
3
RIshi Singh January 10, 2024 3 minute read
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK