Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Color and Size Legends

Public visualization

Viewing a saved revision (read-only)

64dcd7b29e9049a98d70859d2dbc4975

Fork of Color and Size Legends

0 stars1🌍 Public
SSumayaar
Last edited Jun 11, 2022
Created on Jun 11, 2022

This example demonstrates two types of legends using D3.js version 5.6.0, rendered as SVG elements. The first legend uses `scaleOrdinal` to map fruit names to colors, displayed as labeled circles. The second legend uses `scaleSqrt` to map a numeric domain to circle radii, with labeled tick marks. Both legends are created using custom reusable functions, `colorLegend` and `sizeLegend`, which manage the enter/update/exit lifecycle for the SVG groups, circles, and text elements.

AI-generated description