Skip to main content
๐ŸŒ Public

Share visualization

Send this visualization to others.

Colour and Size Legends

Public visualization

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

Comments

Sign in to join the discussion.

MIT Licensed