Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
Nnkohdatavis
Last edited Jul 30, 2020
Created on Jul 30, 2020

This example demonstrates two reusable legend components in D3 v5: a color legend for ordinal scales and a size legend for quantitative scales. The color legend maps fruit names to distinct colors using `scaleOrdinal`, while the size legend uses `scaleSqrt` to represent numeric ticks as proportional circle radii. Both legends are rendered as SVG groups with circles and text, using `.call()` to apply the component functions. The size legend filters out zero values and reverses tick order to display larger circles first.

AI-generated description
MIT Licensed

Similar vizzes