COLOR AND SIZE LEGENDS
✓ Published1🌍 Public
Jjons288
Last edited Sep 29, 2018
Created on Sep 29, 2018
This example demonstrates two distinct legend styles: a categorical color legend and a quantitative size legend. The color legend uses an ordinal color scale to map fruit names to distinct colors, while the size legend uses a square-root scale to visualize numeric values through circle radii. Both legends are rendered as SVG groups with tick marks, using D3's `selectAll` and `merge` for efficient updates. The code builds legends from reusable functions `colorLegend` and `sizeLegend`, which append circles and text elements to an SVG canvas.
AI-generated descriptionMIT Licensed