Color and Size legends
✓ Published0🌍 Public
This example demonstrates two reusable legend components for scatterplot-style visualizations. A color legend maps ordinal domain values (apple, lemon, lime, orange) to a d3.scaleOrdinal color range, while a size legend uses d3.scaleSqrt to encode numeric ticks as proportional circle radii. Both legends are implemented as functions that bind SVG groups with enter/merge/exit selections, positioning circles and text labels with custom spacing and offsets. The SVG rendering uses D3 v6 APIs including selection.call, selection.merge, and scale.ticks.
AI-generated descriptionMIT Licensed