Colour and size legends
✓ Published0🌍 Public
This example demonstrates two custom SVG legends built with D3 v5 and React, rendered on a single 960x500 pixel canvas. The color legend uses `scaleOrdinal` to map fruit categories to distinct hues, while the size legend employs `scaleSqrt` to encode numeric tick values as proportional circle radii. Both legends are generated through reusable functions that manipulate SVG groups, circles, and text elements, with spacing controlled via `transform` translations and dynamic text offsets. The visualization illustrates how to compose and position independent legend components side by side within a single SVG container.
AI-generated descriptionA bare minimum HTML page.
See also React Starter.
MIT Licensed