Skip to main content
100%

D3 Color and Size Legends

✓ Published0🌍 Public
Rrdeichert
Last edited Dec 16, 2019
Created on Dec 16, 2019

This example demonstrates two reusable D3 legend components rendered as SVG: a color legend for ordinal scales and a size legend for quantitative scales. The color legend displays fruit categories as colored circles with labels, while the size legend visualizes numeric values through scaled circle radii. Both components use D3’s selection join pattern with `selection.enter` and `selection.merge` to update elements. The size legend relies on `scaleSqrt.ticks` to generate tick values, while the color legend maps ordinal domain values to a range of colors via `scaleOrdinal`.

AI-generated description
MIT Licensed

Similar vizzes