Skip to main content
100%

Color and Size legends

✓ Published0🌍 Public
JJuyeonee
Last edited Jul 21, 2021
Created on Jul 20, 2021

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 description
MIT Licensed

Similar vizzes