Member-only story

Bar Chart with Word Cloud Filled Bars

Using D3.js and just 100 lines of JavaScript

Russell Lim
4 min readDec 3, 2021
Bar chart with one bar for each letter. Each bar is filled with a word cloud with popular names for that starting letter. E.g. the first bar is A, with 14% of all babies. Popular A names include Ava, Amelia, Aiden, Alexander, etc.
Chart created by author (this article explains how!)

My wife and I are expecting our second baby any day now. 😅
With babies in my brain, I spent some time designing this baby name data visualisation. I have combined word clouds with a bar chart to convey:

  • which first letters were the most common for baby names, and
  • which names were most popular for each first letter.

Word clouds are usually not the best way to represent data for precise comparisons. But they are good for a quick visual overview, and here I think they work well. Although it may not be clear from the chart whether Ava or Amelia was the more popular name, for example, it is immediately clear that these were both very popular names starting with A.

Below are the steps I used to prepare the data and create the chart, taking advantage of the D3 JavaScript library.

1. Preparing the Data

The data, published by the United States Social Security Administration, came in text file format. Each row contains a name, gender and count. I copied the text and stored it as a JavaScript string:

--

--

Russell Lim
Russell Lim

Written by Russell Lim

I teach high school mathematics in Melbourne, Australia. I like thinking about interesting problems and learning new things.

No responses yet

Write a response