Skip to main content
100%

Color and size legend

✓ Published0🌍 Public
RRoger Yu-Hsiang Lo
Last edited Mar 28, 2020
Created on Feb 14, 2020
Forked from Click to select

Two reusable D3 legend components illustrate how to encode data with color and size. The color legend maps ordinal categories to colored circles using `d3.scaleOrdinal`, while the size legend uses `d3.scaleSqrt` to size circles by numeric ticks. Both render as SVG groups with `.tick` classes, updating via D3's data-join pattern. The legends demonstrate custom legend-building with explicit spacing, text offsets, and tick filtering.

AI-generated description
MIT Licensed

Similar vizzes