Skip to main content
100%

Color and size legend

✓ Published0🌍 Public
YYedrup
Last edited Mar 22, 2020
Created on Mar 21, 2020

This example demonstrates two custom D3 legend components rendered as SVG: a color legend for categorical values and a size legend for continuous quantitative values. The color legend uses `scaleOrdinal` to map fruit names to distinct colors, while the size legend employs `scaleSqrt` to translate numeric ticks into circle radii. Both legends rely on D3 v5’s data join pattern with enter/merge/exit selections, and the size legend filters out zero values from `ticks()` while setting explicit spacing and circle fill properties.

AI-generated description
MIT Licensed

Similar vizzes