Skip to main content
100%

Bowl of Fruit - General Update Pattern Special Cases

✓ Published0🌍 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
MIT Licensed

Similar vizzes