Skip to main content
100%

Color Legend

✓ Published0🌍 Public
CChristine Lanser
Last edited Oct 7, 2020
Created on Oct 7, 2020
Forked from Color Legend

This example demonstrates a versatile legend system for data visualizations, showing both a color legend for categorical data and a size legend for quantitative data. The color legend maps fruit names to distinct colors, while the size legend represents numeric tick values with proportionally scaled circles. The visualization uses D3 v5's scaleOrdinal and scaleSqrt APIs to generate the respective scales. The code constructs SVG groups for each legend item, positioning circles and text vertically with configurable spacing and offsets, and employs enter/exit animations for dynamic updates.

AI-generated description

creating Color and Size Legends

MIT Licensed

Similar vizzes