Bowl of Fruit - General Update Pattern Special Cases
This example demonstrates two custom legend components for categorical and quantitative scales, applied to a fruit-themed visualization. The color legend maps fruit types (apple, lemon, lime, orange) to distinct colors, while the size legend uses a square-root scale for proportional circle sizing. Built with D3 v5, it uses selection joins (`enter`, `merge`, `exit`) to handle updates dynamically, rendering SVG elements with `d3.scaleOrdinal` and `d3.scaleSqrt`. The code defines reusable functions for both legends, which are called on separate SVG groups with explicit spacing and text offsets.