Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color and Size Legend

Public visualization

Viewing a saved revision (read-only)

7d1236ac9c23436d88234dc39fd8ae89

Color and Size Legend

0 stars0🌍 Public
Ssploitfun
Last edited May 8, 2020
Created on May 8, 2020

This example demonstrates two legend types for visualizing data: a color legend and a size legend created side by side in an SVG. The color legend maps categorical fruit names (apple, lemon, lime, orange) to distinct colors using a d3.scaleOrdinal, while the size legend uses a range of numeric values to create circles of varying radii. Both legends are rendered through d3 data joins, where each group contains a circle and a text label positioned with transform attributes and spacing constants. The visualization uses d3.v5 and employs the colorLegend and sizeLegend custom functions to generate the reusable legend components.

AI-generated description