🌍 Public
Viewing a saved revision (read-only)
c1865bc2e50c4c87b139f6c2f03c158d
Color and Size Legends
Ssteveaigbe
Last edited Nov 21, 2020
Created on Nov 21, 2020
This example demonstrates two types of legends for mapping data to visual properties. The color legend uses a `scaleOrdinal` to map categorical names to colors, while the size legend uses a `scaleSqrt` to map numeric values to circle radii with tick marks. Both legends are implemented as reusable functions that append SVG `<g>` elements containing circles and text labels. The code uses D3 v5's selection and merge pattern to efficiently update the legend elements.
AI-generated description