Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

color and size legends

Public visualization

color and size legends

0 stars0🌍 Public
JJenny
Last edited Jul 14, 2019
Created on Jul 12, 2019
Forked from Nested elements

Two reusable legend components illustrate categorical and quantitative scales in D3 v5. The color legend maps four fruit names through `d3.scaleOrdinal` to distinct hues, displaying circles with aligned text labels. The size legend uses `d3.scaleSqrt` to represent numeric ticks from 0 to 10 as proportionally sized circles. Both legends render in SVG, with the size legend filtering out zero values and reversing tick order. The code demonstrates shared update patterns using `selection.merge` for enter and exit transitions.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed