Skip to main content
100%

Color and size legends

✓ Published1🌍 Public
VVaggelisKlt
Last edited May 19, 2020
Created on May 19, 2020

This example demonstrates two types of legend encodings for data visualization: a color legend mapping ordinal categories to hues, and a size legend scaling circles according to a square-root scale. The color legend displays fruit names with distinct colors, while the size legend shows numeric ticks with proportional circle radii. Built with D3 v5, the visualization uses `selectAll` and `.enter().append()` to construct SVG groups, circles, and text elements. Custom `colorLegend` and `sizeLegend` functions control the layout, with positioning handled via `attr('transform', ...)` and scales defined by `scaleOrdinal` and `scaleSqrt`.

AI-generated description
MIT Licensed

Similar vizzes