Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Animated Bubble Chart

Creating Animated Bubble Charts using D3.


This repository contains code to create your own animated bubble chart.

It goes along with the tutorial here:

A live version of this code is here:


D3 needs to be run from a webserver due to how it imports data files.

See more here:

So, to run this visualization locally, from the Terminal, navigate to the directory you checked it out to

 cd ~/code/path/to/gates_bubbles

Then start a webserver locally. If you are on a Linux or Mac, you should be able to use python's built in webserver:

 python -m SimpleHTTPServer 3000

I always use Ruby's thin gem to get things started

 gem install thin # <- just do once
 thin start

Once the server has started, open up your web browser to:

And you should see your bubbles!

Pure JS version

For folks not wanting to dive into Coffeescript, I've added a JS version that is just the compiled Coffeescript. You can see it by navigating to the page:

This was compiled with Coffeescript 1.8, using the command:

 coffee -o js/ -c coffee/

If you would like to try it on your own modified version of the Bubbles.

Remove the Google Analytics Code!

Because this same code is used to run the live version on my site, I (perhaps foolishly) added my own Google Analytics code to the index.html page.

If you build anything with this - and that thing gets put on the internet, just try to remember to change the GA code down at the bottom of the page. At least you could remove the GA call.

Things to consider

Here are a few things that may be issues for you, or may not be

  • Written in Coffeescript

Coffeescript compiles down to JavasScript, and is a really fun language to learn. Try it out!

But if you want, you should be able to compile this tutorial back down to JavaScript - and start from there. People in the comments of the tutorial have already done this.

  • Bubbles might not be the answer to your problems

While the bubbles are flashy and are fun to watch move around, they may not be the best visual form to display your information in. In most cases, when bubbles are used to encode a single variable, the two dimensional bubble inflates and obscures the one dimensional value it is attempting to display.

Kaiser Fung hates bubble charts. You can see lots of reasons why here:

Just keep in mind when you are working with your data.