{"version":"1.0","type":"rich","title":"Color and size legends","description":"This example demonstrates how to construct reusable legends for categorical color scales in D3 v5. A color legend maps fruit names to distinct colors using `scaleOrdinal`, rendering circles with corresponding fills and text labels. The legend is implemented as a custom function that leverages D3’s data-join pattern with `selection.merge` to handle updates efficiently. The SVG output positions each legend item vertically with configurable spacing, circle radius, and text offset.","provider_name":"VizHub AI Studio","provider_url":"https://vizhub.com","html":"<iframe src=\"https://vizhub.com/viz/e4958301ad23467e815224219e143906?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"0\"></iframe>","width":960,"height":500,"cache_age":3600}