Color and Size Legends
✓ Published0🌍 Public
Ooptimizeresume
Last edited Jan 15, 2021
Created on Jan 13, 2021
This example demonstrates how to create reusable color and size legends in D3 v5. It uses two custom functions, `colorLegend` and `sizeLegend`, to render ordinal color scales and square-root size scales as SVG groups. The color legend maps fruit categories to distinct fills, while the size legend displays tick values with proportional circle radii. Both legends use D3’s selection joins and scale APIs (`scaleOrdinal`, `scaleSqrt`) to update efficiently.
AI-generated descriptionMIT Licensed