Skip to main content
100%

General Update Pattern Special Cases

✓ Published0🌍 Public
DDi Cui
Last edited May 28, 2023
Created on May 28, 2023

This example demonstrates two special cases of D3’s general update pattern: categorical color legends and quantitative size legends, both rendered as SVG groups. It uses `d3.scaleOrdinal` and `d3.scaleSqrt` to map fruit names and numeric values to visual encodings, with `selection.merge()` handling enter and update selections. The color legend shows circles with labels for apple, lemon, lime, and orange, while the size legend displays five tick marks with proportional radii. Data comes from hardcoded domains and ticks generated via `sizeScale.ticks()`.

AI-generated description
MIT Licensed

Similar vizzes