Skip to main content
100%

Legend and colors

✓ Published0🌍 Public
Ppaularl
Last edited Jan 28, 2020
Created on Jan 28, 2020

This example demonstrates how to build reusable legends for mapping data values to visual encodings. A color legend uses an ordinal scale with fruit names and distinct hues, while a size legend applies a square-root scale to represent numeric ticks with circles of varying radii. The code defines `d3.scaleOrdinal()` and `d3.scaleSqrt()` with SVG rendering, and updates legends through enter/merge/exit selections. Both legends are generated as reusable functions called via `.call()`, with circles and text positioned using `spacing` and `textOffset` parameters.

AI-generated description
MIT Licensed

Similar vizzes