Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
NNita
Last edited Sep 24, 2018
Created on Sep 24, 2018

This example demonstrates how legends can visualize both ordinal color scales and quantitative size scales. A color legend maps fruit names to distinct hues using `d3.scaleOrdinal`, while a size legend translates a numeric range into varying circle diameters via `d3.scaleSqrt`. Both legends are constructed as reusable functions that append SVG `<g>` groups and circles, using D3’s selection and merge patterns to handle updates. Text labels accompany each circle, positioned relative to the circle’s radius.

AI-generated description
MIT Licensed

Similar vizzes