Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color Legend

Public visualization

Color Legend

0 stars1🌍 Public
LLudovicGouverneur
Last edited Dec 5, 2018
Created on Dec 5, 2018

This example demonstrates how to create color and size legends in D3 v5 using reusable functions. It shows ordinal color scaling mapping fruit names to pastel colors, and a square-root size scale with transitioning circles. The SVG rendering includes animated transitions on the size legend, while text labels accompany each legend entry. The code uses `d3.scaleOrdinal`, `d3.scaleSqrt`, and D3's selection join pattern with `.enter()` and `.merge()`.

AI-generated description

Learn about update pattern - from video

Comments

Sign in to join the discussion.

MIT Licensed