Color Legend
✓ Published0🌍 Public
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 descriptioncreating Color and Size Legends
MIT Licensed