🌍 Public
Color and Size Legends
This example demonstrates how color and size legends can be created using D3.js v6, displaying three categorical items (apple, lemon, lime) mapped to distinct colors. It shows two legends: one for color encoding using a categorical color scale and another for size representation through circle radius. The implementation uses a custom `colorLegend` function that leverages D3's selection API with `selectAll`, `enter`, `merge`, and `exit` patterns to manage SVG groups of circles and text labels. The legend items are vertically spaced and annotated with text labels, with the entire SVG rendered using vector graphics.
AI-generated descriptionMIT Licensed
Comments
Sign in to join the discussion.