Skip to main content
100%

Color and Size Legends.js

✓ Published0🌍 Public
NNeepaB
Last edited Dec 28, 2020
Created on Dec 25, 2020

Two reusable D3 legend components demonstrate how to encode data through color and size. The color legend uses `scaleOrdinal` to map fruit categories to distinct hues, while the size legend uses `scaleSqrt` with tick marks to represent numeric values. Both render as SVG groups with circles and text labels, updating through D3's data join pattern. The examples show how legends can be built using `selection.call` with custom functions and `merge` for enter/update transitions.

AI-generated description
MIT Licensed

Similar vizzes