Skip to main content
100%

Color legend

✓ Published0🌍 Public
AAnShed
Last edited Jun 29, 2020
Created on Jun 29, 2020
Forked from Cars Scatter Plot

This example demonstrates two reusable legend components for D3 visualizations: an ordinal color legend for categorical data and a quantitative size legend for numeric scales. The color legend maps fruit names to distinct colors, while the size legend uses a square-root scale to map values from 0 to 10 to circle radii. Both legends are rendered as SVG using d3.select, append, and merge operations, with the color legend applying a scaleOrdinal and the size legend using scaleSqrt. The code uses D3 v5 APIs including selection.call, data, and attr to construct the tick groups dynamically.

AI-generated description
MIT Licensed

Similar vizzes