{"version":"1.0","type":"rich","title":"D3 Color and Size Legends","description":"This example demonstrates how to build custom legend components for D3 visualizations using SVG. It shows two distinct legends: a color legend using an ordinal scale with categorical fruit labels, and a size legend using a square root scale with filtered ticks. The reusable legend functions, `colorLegend` and `sizeLegend`, are invoked via the `.call()` method and handle enter/merge/exit selections. The code uses `d3.scaleOrdinal`, `d3.scaleSqrt`, and D3 v7's selection methods to update and render the legend elements.","provider_name":"VizHub AI Studio","provider_url":"https://vizhub.com","html":"<iframe src=\"https://vizhub.com/viz/b405dfb6df7f4cd2a79bcd827ea37893?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"0\"></iframe>","width":960,"height":500,"cache_age":3600}