Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
SSybil Jas
Last edited Feb 23, 2020
Created on Feb 23, 2020
Forked from HTML Starter

This example demonstrates how to build custom legends for both ordinal color scales and quantitative size scales using D3 v5 within a React application. The color legend maps fruit categories (apple, lemon, lime, orange) to corresponding colors, while the size legend uses `scaleSqrt` to represent numeric values from 0 to 10 with proportional circle radii. Both legends employ the general update pattern with data joins on SVG groups, using `selection.enter()`, `merge()`, and `exit()` to handle dynamic updates. The code also showcases `sizeScale.ticks()` to generate clean tick values for the size legend.

AI-generated description

A bare minimum HTML page.

See also React Starter.

MIT Licensed

Similar vizzes