Skip to main content
100%

Color And Size Legend Ludo

✓ Published0🌍 Public
LLudovicGouverneur
Last edited Dec 5, 2018
Created on Dec 5, 2018
Forked from Color Legend

This example demonstrates two distinct legend designs for mapping data to visual encodings in D3 v5: a qualitative color legend and a combined size and color legend. The qualitative legend assigns categorical colors to fruit names using `d3.scaleOrdinal`, while the size legend uses `d3.scaleSqrt` to map numeric values to circle radii, with a corresponding `scaleOrdinal` color scale. The code implements reusable legend components (`colorLegend.js` and `sizeLegend.js`) that update via D3's select-merge-append pattern. The size legend animates its circle positions and text labels over 1000 milliseconds using `.transition().duration(1000)`, while both legends render as SVG elements with `<circle>` and `<text>` marks.

AI-generated description

Learn about update pattern - from video

MIT Licensed

Similar vizzes