Color and Size Legends
✓ Published1🌍 Public
This example presents two interactive legends built with D3.js v5. A categorical color legend maps fruit names—apple, lemon, orange, and lime—to distinct colors using `d3.scaleOrdinal()`, while a sequential size legend uses `d3.scaleSqrt()` to represent numeric values from 0 to 10 with varying circle radii. The code employs D3's `transition()` method to animate the circles’ radii from zero to their final sizes, and both legends are rendered as SVG groups with tick marks, circles, and text labels.
AI-generated descriptionMIT Licensed