Color and Size Legends
Two legends demonstrate independent D3 color and size scales. A color legend maps ordinal domains like “apple” and “lemon” to discrete hues, while a size legend uses a square-root scale with tick marks and semi-transparent circles. Both are rendered as SVG groups via custom reusable functions, `colorLegend` and `sizeLegend`, which bind data to enter/merge/exit selections. The code uses D3 v5 APIs such as `scaleOrdinal`, `scaleSqrt`, and `scaleDiverging` (imported but unused), with text styling applied through CSS classes.