Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
LLeora Wenger
Last edited Dec 11, 2018
Created on Dec 6, 2018

This example demonstrates two reusable D3.js legend components: a color legend for ordinal scales and a size legend for quantitative scales. The color legend displays four fruit categories with distinct colors, while the size legend uses a square-root scale with four reversed ticks. Both legends are implemented as custom D3.js functions that accept an SVG group and configuration props, using d3.scaleOrdinal and d3.scaleSqrt. The SVG rendering includes labeled circles with custom spacing and text offsets, styled via CSS with sans-serif fonts and black stroke outlines.

AI-generated description
MIT Licensed

Similar vizzes