Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
PPaul Kumar
Last edited Sep 24, 2020
Created on Sep 24, 2020

This example demonstrates how to create separate legends for ordinal color scales and quantitative size scales using D3 v5. A color legend maps fruit names to distinct colors with equally spaced circles, while a size legend displays circular markers whose radii scale proportionally to numeric values using `scaleSqrt`. Both legends are implemented as reusable functions via `selection.call()`, with the color legend using `scaleOrdinal` and the size legend using `scaleSqrt().ticks()` to generate tick values. The SVG rendering includes custom text and circle styling defined in external CSS.

AI-generated description
MIT Licensed

Similar vizzes