Skip to main content
100%

Color and Size Legend

✓ Published0🌍 Public
EEdoardoRegini
Last edited Apr 13, 2020
Created on Apr 13, 2020

Two reusable D3 legends demonstrate how to encode data through color and size. The color legend uses `d3.scaleOrdinal` to map fruit names to categorical colors, while the size legend uses `d3.scaleSqrt` to map numeric values to circle radii. Both legends are implemented as custom D3 functions that append SVG circles and text elements, using `.merge()` for efficient updates and `.exit().remove()` for cleanup. The rendering is entirely SVG-based within a single `<svg>` element, styled with CSS classes.

AI-generated description
MIT Licensed

Similar vizzes