Skip to main content
100%

Color and size legends with D3.js!

✓ Published0🌍 Public
Fforcox43
Last edited Jul 16, 2020
Created on Jul 16, 2020

This example demonstrates how to build custom color and size legends using D3.js v5 in a React application. It shows an ordinal color scale mapping fruit names to distinct colors, alongside a square-root size scale with five ticks rendered as proportionally sized circles. The code defines reusable legend components that use selection joins with `merge()` and `exit().remove()` to manage SVG groups dynamically. Both legends render as SVG, with circles and text positioned using transform attributes and spacing parameters.

AI-generated description

A bare minimum HTML page.

See also React Starter.

MIT Licensed

Similar vizzes