Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 13.3 — Choropleths and Symbol Maps
Data Visualization · Example 2 of 3

Symbols sized by area, with zero and missing values

A square-root scale gives a 2.5 times bigger area for 2.5 times more docks.

A choropleth colours each area by a value, and a symbol map puts a circle on each place. Both are easy to draw and easy to get wrong: totals follow size, classes decide the colours, a circle's area (not its radius) must show the value, and zoom must not grow the symbols.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Add a legend to the choropleth: four squares with the class ranges (scale.thresholds() gives the breaks of a quantize scale).

02

Write circleRadius(value, max, maxRadius) that returns 0 for missing, zero or negative values, and a square-root scaled radius otherwise.

Explain it without notes

01

Why is a choropleth of total rides less useful than one of rides per dock?

02

How do quantize, quantile and threshold scales differ, and when does each mislead?

03

Why must a circle's radius be the square root of the value?

04

How do you stop circles growing when the map zooms?

Symbols sized by area, with zero and missing values

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

12 docks vs 30 docks: the value is 2.5x
  sqrt scale: radii 10.1 and 16.0 -> area 2.5x (right)
  linear radius: 6.4 and 16.0 -> area 6.2x (the 30-dock station looks about 6 times bigger)
radius for 0: 0 | missing: 0 | negative: 0 | raw scale given a missing value: undefined
circles: 25 | pairs that overlap: 6 | biggest first: Clock Tower 30