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
Aarieltonglet
Last edited Oct 14, 2019
Created on Oct 1, 2019

Two adjacent legends illustrate how to construct reusable D3 legend components. A color legend uses `d3.scaleOrdinal` with fruit types mapped to red, yellow, orange, and green, rendering circles with corresponding fills and text labels. A size legend uses `d3.scaleSqrt` to map values 0–10 to circle radii, with ticks generated via `sizeScale.ticks` and positioned by cumulative spacing. Both legends are appended as SVG groups, with enter/merge/exit selections managing dynamic updates.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed