Color Legend - Swatches
✓ Published0🌍 Public
A set of colored squares arranged in a vertical list functions as an ordinal color legend, mapping fruit names to distinct hues. The visualization demonstrates reusable legend logic through D3 v5, using `scaleOrdinal` for the color mapping and SVG `<rect>` elements for the swatches. The custom `colorLegend` function creates an enter-merge-exit pattern to bind data, with each row positioned via a translate transform. Text labels are placed beside each square, with spacing controlled by `circleRadius`, `circleSpacing`, and `textOffset` parameters.
AI-generated descriptionMIT Licensed