Color and Size Legends
✓ Published1🌍 Public
Jjay
Last edited Feb 18, 2020
Created on Feb 18, 2020
This example demonstrates how to build a color legend using D3 v5, displaying categories apple, lemon, limes, and orange with distinct colors and circular markers. The visualization uses a custom `colorLegend` function that binds ordinal scale domain values to groups, appending circles and text labels with specified spacing and offsets. The code imports `select` and `scaleOrdinal` from D3, applies the legend to an SVG canvas, and sets explicit styling for text, circles, and background in CSS.
AI-generated descriptionMIT Licensed