Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color and Size Legends

Public visualization

Viewing a saved revision (read-only)

5b5803c67878431b971c28e1e1572594

Color and Size Legends

0 stars0🌍 Public
Ssemiramiss2020
Last edited Sep 30, 2020
Created on Sep 30, 2020

This example illustrates two distinct legend types for scatterplots using D3 v5 and SVG rendering. It combines a categorical color legend with an ordinal scale, showing fruit names mapped to distinct hues, and a quantitative size legend using a square-root scale for proportional circles. The size legend generates ticks from the scale and positions text offset by each circle’s radius. Both legends are built with reusable functions that append and update `g` elements, demonstrating a consistent pattern for interactive legend components.

AI-generated description