🌍 Public
Viewing a saved revision (read-only)
1b472d87e1dd403a920ff90886f0969a
Color and Size Legends
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