Color and Size Legends
✓ Published0🌍 Public
PPenguin-jpg
Last edited Sep 18, 2023
Created on Sep 18, 2023
This example demonstrates how to create a dual-legend visualization for categorical data, using both color and size to encode fruit type. It shows apples and lemons as scaled circles arranged in a bowl-shaped container rendered in an SVG. The implementation uses d3.v5’s `select` and `scaleOrdinal` APIs, with `colorLegend` defining the legend’s layout and `radiusScale` implicitly controlling circle sizes. The data is a hardcoded array of fruit types, and the rendering relies on SVG shapes with styled strokes and fills.
AI-generated descriptionMIT Licensed