Skip to main content
100%

Color and size legend vertical

✓ Published0🌍 Public
JJoachim Klug
Last edited Sep 28, 2020
Created on Sep 28, 2020

This example shows two vertical legends in a single SVG: a color legend mapping four fruit names to distinct colors, and a size legend mapping a numeric scale to circle radii. The color legend uses `d3.scaleOrdinal` with a custom domain and range, while the size legend uses `d3.scaleSqrt` to generate five tick values via `ticks`. Both legends are built through reusable functions that render groups of circles and text using D3’s selection and merge API, with spacing and text offsets controlled by parameters passed in the `call` method.

AI-generated description
MIT Licensed

Similar vizzes