Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color Legend

Public visualization

Viewing a saved revision (read-only)

1ec72c136643432b9eb0c3a8f4700b3b

Color Legend

0 stars0🌍 Public
Nnsadath
Last edited Dec 14, 2020
Created on Dec 14, 2020

This example demonstrates two types of legends for mapping data to visual encodings: a color legend for categorical values and a size legend for quantitative values. The color legend displays circles colored via a d3.scaleOrdinal mapping fruit names to colors, while the size legend uses d3.scaleSqrt to represent numeric ticks as varying circle radii. Both legends are rendered as SVG groups with d3-selection, using join patterns to update circle and text elements. The code is built with React and D3 v6, with the legends generated procedurally from scales rather than external data.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.