Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
MMounikaBeerelly
Last edited Jun 10, 2020
Created on Jun 9, 2020

This example demonstrates how to create separate legends for ordinal color scales and quantitative size scales in D3 v5. The color legend uses a `scaleOrdinal` with fruit names mapped to distinct colors, while the size legend uses `scaleSqrt` to map numeric values to circle radii. Both legends are rendered as SVG groups using custom reusable functions that bind data to enter/merge/exit selections, positioning circles and text labels with transform attributes and spacing offsets.

AI-generated description
MIT Licensed

Similar vizzes