🌍 Public
Viewing a saved revision (read-only)
d4c8150f578245beb9a849a8fcfc0471
Color and Size Legends
This example demonstrates two custom D3.js legends rendered as SVG within a React application. The color legend maps categorical fruit names to distinct colors using `scaleOrdinal`, while the size legend uses `scaleSqrt` to encode numeric tick values as circle radii. Both legends are constructed with D3's data join pattern (`selectAll`, `enter`, `merge`, `exit`), displaying circles and text labels. The color legend places swatches vertically, and the size legend scales circle areas according to the square-root scale, with tick generation via `sizeScale.ticks`.
AI-generated descriptionA bare minimum HTML page.
See also React Starter.