This video is available to students only

Adding the precipitation bubbles

Next, we learn about ordinal scales and create the inner ring of circles to show the precipitation probability and type for each day.

Adding the precipitation bubbles#

Next, we want to add a row of bubbles corresponding to each day's precipitation. We have two relevant metrics: probability of precipitation and type of precipitation. Let's visualize the probability with the size of the bubble and the type with the color of the bubble. This way, we can play to both dimensions' strengths -- a large amount of blue will correspond to a high probability of rain. And we won't see a lot of a color if we're not confident that it did precipitate.

To start, we'll create a scale to convert the probability of precipitation to the radius of a bubble. We'll make these circles a little smaller than our cloud circles, since they're closer to the middle of our circle (and thus have less space).

This code will go at the end of our Create scales step.

Next, we'll list out the types of precipitation in our dataset, then create a color scale mapping those types to different colors. We'll want to use an ordinal scale, since this is an ordinal metric, and can be placed in categories with a natural order (remember the types of data we learned in Module 6?).

 

This page is a preview of Fullstack D3 Masterclass

No discussions yet