Skip to main content
100%

Color and Size Legends

✓ Published0🌍 Public
NNaveenaS12
Last edited Aug 18, 2020
Created on Aug 18, 2020

This example demonstrates two reusable legend components for scatterplot-style visualizations: a color legend for ordinal categories and a size legend for quantitative values. The color legend maps fruit names to distinct hues using `d3.scaleOrdinal`, while the size legend uses `d3.scaleSqrt` to encode numeric ticks as proportional circle radii. Both legends are rendered as SVG groups via data joins, with circles and text labels. The code uses `d3-selection` methods like `selectAll`, `enter`, and `merge` to manage updates, and `d3.ticks` to generate tick values.

AI-generated description
MIT Licensed

Similar vizzes