🌍 Public
Color and size legends
This example demonstrates a color legend with two categorical entries, “apple” and “lemon,” each represented by a colored circle and a text label. Using D3.js v5, the `scaleOrdinal` API maps the categories to distinct colors, while a custom `colorLegend` function positions the circles and labels horizontally across the SVG canvas. The visualization is rendered as SVG elements, with the legend items spaced based on an offset calculation and the height parameter passed from the parent SVG.
AI-generated descriptionMIT Licensed
Comments
Sign in to join the discussion.