Skip to main content
100%

Color and Size legend

✓ Published4🌍 Public
Ppplomith
Last edited Mar 20, 2021
Created on Mar 17, 2021

This example demonstrates two reusable legend components for scatterplots: a color legend using an ordinal scale and a size legend using a square-root scale. The color legend maps fruit names to red, yellow, green, and orange circles, while the size legend displays five circular ticks sized proportionally to values from 0 to 10. Both are built with D3 v5, using `d3.scaleOrdinal`, `d3.scaleSqrt`, and the enter-merge-exit pattern to bind SVG groups, circles, and text elements.

AI-generated description
MIT Licensed

Similar vizzes