How to Create an Animated Bar Chart
Step-by-Step Tutorial of Bar Chart Race with Flourish
I’m sure many of you have seen this bar chart race illustrating what inflation looks like. Bar Chart Race is a great way to display numerical changes over time and the animation component enables a comprehensive representation of time-series data.
In this article, I’m going to show you step-by-step from getting the data to completing the visual.
Sneak peak of the final product:
Data Source
Since we would need time series data for the bar chart race, I chose the United States’ Consumer Price Index data from 1957 to 2022 (source: BLS Beta Lab) which perfectly suits the need. You can find many categories on this site, but for this demonstration I limited them to Medical, Transportation, Food, Energy, Gas, and Apparel.
Keep in mind each category comes in a .csv file, so we need to merge all the dataframes together. If you would like to see the detailed data cleaning process, please visit the United States CPI Prediction:
Creating the Chart
Step 1
We are going to create the chart with Flourish, which would generate the chart for us without writing a single line of code. It also allows us to fully customize the look (e.g. color, label, image, etc.).
Go ahead and click the link below, and register an account (FREE) on Flourish if you don’t have one already.
Step 2
Now that you have created your account, log in and click on the Bar chart race template which would look similar to this:
If you struggle to find the link, you can also click here which will take you directly to this template:
Step 3
Now click on the blue button ‘Create visualization’, and it will take you to this page with the default dataset.
Notice there are two tabs on the center of the page: ‘Preview’ and ‘Data’. Keep in mind if you make any adjustment, you can switch to the ‘Preview’ page to view the changes.
Now let’s navigate to the ‘Data’ page which looks like this:
Notice the blue bottom at the top right, this allows us to upload our own data. And we will upload the CPI data from here.
Step 4
Now we have uploaded the data, we need to tell Flourish which column will be on the x-axis (‘Label’) and what quantitative values will be fed to the bar (‘Values’).
Other than the required ‘Label’ and ‘Values’, ‘Categories’ and ‘Image’ are optional.
In this example, I’m putting column A (the categories) as ‘Label’; column C-ADI which are all the columns with time stamp; and column B with image urls that would be displayed next to the bar.
Step 5
Now if you go the the ‘Preview’ page, the bar chart race should be up and running! To make the chart pretty, here’s a couple things you can play around with.
- Colors
Flourish gives us the full control of displaying the colors. There are some built-in color palettes and you can also customize the palette however you wanted.
Here I’m using my own neutral color palettes with 6 colors.
- Labels
We can change the size the display settings of the labels. I reduced the size so that all words can be properly displayed on the screen without being cut off.
- Images
In this setting, we can adjust the size and fitting of the images on the bars. I created the graphics in Canva, there are also lots of other options (e.g. Adobe illustrator, google images, icons8.com, etc.)
- Title
Don’t forget to add a title to the chart. We can customize the size and display settings of title and subtitle in the ‘Header’ section.
Result
Besides the things I mentioned, there are also a few other settings you can play around with to customize the chart.
Here’s the bar chart race using the steps above:
I hope this tutorial is straight-forward enough for you to follow, and you are able to generate some cool animated bar charts. Flourish is a great visualization tool but it doesn’t get mentioned quite frequently comparing to other popular ones. If you know any other tools please leave a comment below.
As always, I’m open to any questions and feedbacks. Feel free to contact me directly through email or connect with me on LinkedIn. Talk soon.