Skip to main content
100%

Color and Size Legends

✓ Published1🌍 Public
EEdward-Elric233
Last edited Sep 19, 2020
Created on Aug 22, 2020

This example presents two interactive legends built with D3.js v5. A categorical color legend maps fruit names—apple, lemon, orange, and lime—to distinct colors using `d3.scaleOrdinal()`, while a sequential size legend uses `d3.scaleSqrt()` to represent numeric values from 0 to 10 with varying circle radii. The code employs D3's `transition()` method to animate the circles’ radii from zero to their final sizes, and both legends are rendered as SVG groups with tick marks, circles, and text labels.

AI-generated description
MIT Licensed

Similar vizzes