Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Color and Size Legends

Public visualization

Fork of Color and Size Legends

0 stars0🌍 Public
Llrakla
Last edited Dec 29, 2021
Created on Dec 29, 2021

This example demonstrates two reusable legend components created with D3.js v5: a color legend mapping categorical names to colored circles, and a size legend using a square-root scale to encode numeric values through circle radius. The SVG output renders the legends with custom styling, including font size, spacing, and semi-transparent fill colors. The code defines modular JavaScript functions, `colorLegend` and `sizeLegend`, which are called with configuration objects to dynamically generate the legend groups, circles, and text labels based on the specified scale and tick values.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed