Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
BBKirst3
Last edited Mar 10, 2021
Created on Mar 9, 2021
Forked from Nested Example

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 description
MIT Licensed

Similar vizzes