Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Color and Size Legends

Public visualization

Fork of Color and Size Legends

0 stars1🌍 Public
BBlakeMcMurray
Last edited Feb 1, 2021
Created on Feb 1, 2021

This example demonstrates two reusable legend components rendered with SVG: a color legend mapping fruit categories to distinct hues, and a size legend visualizing a square-root scale from zero to ten with five labeled ticks. The color legend uses `scaleOrdinal`, while the size legend relies on `scaleSqrt` and `ticks()` to generate values. Both components are built with D3 v5’s `selection.enter` and `merge` pattern, applying circle radii, fill colors, and text offsets through `attr` and `text` operations. A video tutorial accompanies the code, showing interactive creation in the browser.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed