Skip to main content
100%

Legends

✓ Published0🌍 Public
SSharvariPhadke
Last edited Jan 24, 2021
Created on Jan 24, 2021
Forked from Object Constancy

This example demonstrates two distinct legend styles: a color legend using an ordinal scale for categorical data and a size legend using a square-root scale for quantitative data. The color legend maps fruit names to distinct colors via `d3.scaleOrdinal`, while the size legend uses `d3.scaleSqrt` to translate numeric ticks into varying circle radii. Both legends are rendered as SVG groups using D3's selection and merging API, with circles and text positioned via the `attr('transform', ...)` method. The page integrates custom gradients defined in the SVG defs, though they are not actively applied to the legend marks.

AI-generated description
MIT Licensed

Similar vizzes