color and size legends
✓ Published1🌍 Public
This example demonstrates reusable D3.js legend components for mapping ordinal color scales and continuous size scales. The color legend displays four fruit categories using `d3.scaleOrdinal`, while the size legend uses `d3.scaleSqrt` to visualize values from 0 to 10 with proportional circle radii. Both legends render as SVG groups with circles and text labels, using a data-join pattern for enter/update/exit transitions. The `colorLegend` and `sizeLegend` functions illustrate how to build modular, configurable legend components for scatterplots or choropleth maps.
AI-generated descriptionMIT Licensed