🌍 Public
Viewing a saved revision (read-only)
66592e1317c040c7a6a5a7658d0c2ccb
Color and Size Legends
This example demonstrates two methods of creating legends in a D3.js visualization: a categorical color legend showing fruit types with distinct colors, and a quantitative size legend representing numeric values with scaled circles. The SVG-based visualization uses D3 v5's scaling functions, specifically `scaleOrdinal` for the color mapping and `scaleSqrt` for the size mapping, with custom legend constructors `colorLegend` and `sizeLegend` building the tick marks, circles, and labels.
AI-generated description