Skip to main content
100%

Bowl of Fruit - General Update Pattern Special Cases

✓ Published1🌍 Public
AAbishek-Dulal
Last edited Jul 19, 2020
Created on Jul 19, 2020

This example demonstrates two reusable legend components for D3 visualizations: a color legend and a size legend. The color legend maps ordinal fruit categories (apple, lemon, lime, orange) to distinct colors, while the size legend uses a square-root scale to encode tick values as circle radii. Both legends employ the general update pattern, using selection joins with `enter()`, `merge()`, and `exit()` to handle dynamic data. The code uses D3 v5 APIs like `scaleOrdinal`, `scaleSqrt`, and `selection.selectAll` to render SVG circle and text elements with applied transforms.

AI-generated description
MIT Licensed

Similar vizzes