Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
YYF
Last edited Oct 15, 2018
Created on Oct 1, 2018

This example demonstrates how to construct separate color and size legends for ordinal and quantitative scales. The color legend maps categorical fruit names to distinct colors using `scaleOrdinal`, while the size legend uses `scaleSqrt` with `ticks` to display five circle radii. Both legends are built with reusable functions that append SVG `<g>` groups, circles, and text elements. The code uses D3 v5 APIs including `selection.call`, `selection.merge`, and `selection.exit` to update legend components dynamically.

AI-generated description
MIT Licensed

Similar vizzes