Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

General Update Pattern Special Cases

Public visualization

Viewing a saved revision (read-only)

e2c24d6a64ec404dbc3540e27f60f348

General Update Pattern Special Cases

0 stars0🌍 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