🌍 Public
Viewing a saved revision (read-only)
a3b929452c894aa89d0ad7127bf5ce04
Bowl of Fruit - General Update Pattern Special Cases
Jjrodgh
Last edited Jul 19, 2020
Created on Jul 19, 2020
Two legends for ordinal and quantitative scales demonstrate D3's general update pattern with special cases. The color legend maps fruit categories to red, yellow, green, and orange circles using `d3.scaleOrdinal`, while the size legend uses `d3.scaleSqrt` to encode values 0–10 as circle radii, filtering out zero and reversing ticks. Both legends use reusable functions (`colorLegend` and `sizeLegend`) with enter, merge, and exit selections, rendering as SVG. The code relies on D3 v5 APIs including `selection.enter`, `selection.merge`, and `selection.exit`.
AI-generated description