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)

3da00a7e4a91415292aaddd4588734d5

Fork of Color and Size Legends

0 stars0🌍 Public
MMajaha21
Last edited May 4, 2021
Created on May 4, 2021

This example demonstrates reusable legend components for both ordinal color scales and quantitative size scales. The color legend renders colored circles with labels for fruit categories, while the size legend displays circles scaled by magnitude using a square-root scale. Both legends are implemented as custom D3 functions that bind data to SVG groups, using `selection.enter()` and `selection.merge()` for updates. The code utilizes `d3.scaleOrdinal`, `d3.scaleSqrt`, and `scale.ticks()` to generate tick values for the size legend.

AI-generated description