Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Colour and Size Legends

Public visualization

Viewing a saved revision (read-only)

2fa2a6dd7cc9457ea405cfd2f9f2b777

Colour and Size Legends

0 stars0🌍 Public
Jjrodg
Last edited Jul 7, 2020
Created on Jul 7, 2020

This example demonstrates two reusable legend components rendered as SVG: a color legend displaying an ordinal scale with fruit names and assigned colors, and a size legend using a square-root scale to map numeric values to circle radii. The code uses D3 v5 APIs including `scaleOrdinal`, `scaleSqrt`, and `selection.call` to bind the legend functions. Each legend updates through data joins, with circles and text elements positioned using transform attributes and spacing constants.

AI-generated description