Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Bowl of Fruit - General Update Pattern Special Cases

Public visualization

Viewing a saved revision (read-only)

4bf3dfffc1d942598aaff7019113d415

Bowl of Fruit - General Update Pattern Special Cases

0 stars0🌍 Public
Aaidanoconnor1
Last edited Dec 2, 2019
Created on Dec 2, 2019

This example demonstrates two special cases of D3’s general update pattern: color and size legends rendered as SVG groups. The color legend maps categorical fruit names to distinct colors, while the size legend uses a square-root scale with tick marks to represent numeric values. The code explicitly uses `merge`, `enter`, and `exit` selections to handle dynamic updates, with `scaleOrdinal` for colors and `scaleSqrt` for sizing. Both legends are drawn with circles and text, with positioning controlled by transform attributes and spacing props.

AI-generated description