Color and size legend
✓ Published0🌍 Public
This example demonstrates two custom D3 legend components rendered as SVG: a color legend for categorical values and a size legend for continuous quantitative values. The color legend uses `scaleOrdinal` to map fruit names to distinct colors, while the size legend employs `scaleSqrt` to translate numeric ticks into circle radii. Both legends rely on D3 v5’s data join pattern with enter/merge/exit selections, and the size legend filters out zero values from `ticks()` while setting explicit spacing and circle fill properties.
AI-generated descriptionMIT Licensed