Creating Animated Line Charts in Tableau

I recently participated in the #30DayChartChallenge and one of the daily topics was animation, for which I created the below visualisation with a series of animated lines under the map:

This post will highlight some steps to follow to animate line charts in this way.

Create line chart

We’ll start by creating a few line charts using a year dimension on columns. The Line mark type is used as you would expect:

Line marks not animating

To animate the chart, you might think putting the Year dimension on the Pages shelf and selecting Show history is all that’s required. However, this breaks up the line, showing one single-point line per year, which looks like a series of dots:

Use the Circle mark type with Trails

Instead, we can switch the mark type to a Circle and then ensure we show Trails in the History settings and format the Trails to be a thin line:

The line that we now see in the chart above is actually the Trails for All marks formatted as a thin line.

Adding an end point

To give a clear end point to the animation, I decided to add a red circle mark on the final year along with a label showing the final value of the measure. To do this, create a dual axis and use a conditional statement with LAST=0 as the condition. Below is the complete calculation:

Below is the view showing the dual axis and the calculation above, which in this case I added as an ad-hoc calculation directly into the Rows shelf:

Animated lines

When we hit play on the Pages shelf controls, the lines now animate as desired, showing the lines increase in length over time as more years are revealed:

Animating the map

For completeness, below is the view for the animated map. There is no need to adjust the view in this case. Simply add Year to the Pages shelf to animate the map over time. History can be switched off.

Workbook

The workbook containing the animated map and line charts can be downloaded from my Tableau Public profile, here. A workbook walking through the steps in this blog post can be found here.

Creating a GIF or MPG

Sadly, Tableau does not export to animated file formats (as of v2021.1), so to capture the animated GIFs (or an MPG), you can use a program such as ScreenToGif or Snagit. I play the animation in Tableau while capturing the screen output, which these programs can then save to a GIF or MPG as required.

I hope this helps you with creating animations. If you’d like to learn more about how animation works in Tableau, take a look at these more in-depth blog posts:

Animated Transitions in Tableau

Tableau Animation Core Concepts

Thanks for reading!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: