🌍 Public
Viewing a saved revision (read-only)
bc63e40685fe4074aba01bf57086aca8
Color and Size legends
This example builds two custom legends in D3 v5: a color legend mapping fruit names to ordinal colors, and a size legend using a square-root scale. The legends are rendered as SVG groups with circles and text labels. The color legend uses `scaleOrdinal` with a hardcoded domain, while the size legend uses `scaleSqrt` with ticks generated via `sizeScale.ticks()`. Both legends are positioned manually and styled with CSS classes, demonstrating reusable legend components through the `selection.call()` pattern.
AI-generated description