Fork of Color and Size Legends
✓ Published0🌍 Public
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 descriptionMIT Licensed