Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

colour and size legends

Public visualization

Viewing a saved revision (read-only)

9552438aa5aa4c2da8818252925fceac

colour and size legends

0 stars0🌍 Public
KKurt J Nilsen
Last edited Aug 4, 2020
Created on Aug 3, 2020

This example demonstrates two separate SVG legends: a color legend using an ordinal scale mapping fruit names to distinct colors, and a size legend using a square-root scale with circular marks whose radii encode numeric values. The color legend renders colored circles for each category, while the size legend displays five ticks with proportional circle sizes and labels offset by the scaled radius. Both legends use reusable functions (`colorLegend` and `sizeLegend`) built with D3 v5, leveraging `selectAll`, `enter`, `merge`, and `exit` for data joins, with SVG elements styled via CSS.

AI-generated description