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
AAlice Hsieh
Last edited Feb 14, 2020
Created on Feb 14, 2020

Two legends demonstrate independent D3 color and size scales. A color legend maps ordinal domains like “apple” and “lemon” to discrete hues, while a size legend uses a square-root scale with tick marks and semi-transparent circles. Both are rendered as SVG groups via custom reusable functions, `colorLegend` and `sizeLegend`, which bind data to enter/merge/exit selections. The code uses D3 v5 APIs such as `scaleOrdinal`, `scaleSqrt`, and `scaleDiverging` (imported but unused), with text styling applied through CSS classes.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed