Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Color and Size Legends

Public visualization

Viewing a saved revision (read-only)

00cc7dc06b974282968bce21f947d94a

Fork of Color and Size Legends

0 stars0🌍 Public
RRunxin Shao
Last edited May 22, 2023
Created on May 22, 2023

This example demonstrates two common legend types: a color legend mapping ordinal fruit categories to distinct hues, and a size legend using a square-root scale to map numeric values to circle radii. The SVG renderings use d3’s selection API (`selection.selectAll`, `selection.enter`) and custom legend modules (`colorLegend`, `sizeLegend`) that generate tick groups with shapes and labels. The color legend uses `scaleOrdinal` with explicit color ranges, while the size legend calls `scaleSqrt.ticks()` to compute interval breaks, with circles stylized via CSS.

AI-generated description