Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color and size legend

Public visualization

Viewing a saved revision (read-only)

3e026b7e4c1a457095116858445c22b1

Color and size legend

0 stars0🌍 Public
YYedrup
Last edited Mar 22, 2020
Created on Mar 21, 2020

This example demonstrates two custom D3 legend components rendered as SVG: a color legend for categorical values and a size legend for continuous quantitative values. The color legend uses `scaleOrdinal` to map fruit names to distinct colors, while the size legend employs `scaleSqrt` to translate numeric ticks into circle radii. Both legends rely on D3 v5’s data join pattern with enter/merge/exit selections, and the size legend filters out zero values from `ticks()` while setting explicit spacing and circle fill properties.

AI-generated description