Skip to main content
100%

Legend experimenting

✓ Published0🌍 Public
MMaciek Sitkowski
Last edited Sep 4, 2020
Created on Sep 4, 2020

This example demonstrates how to build reusable color and size legends for D3 visualizations. It shows a color legend using d3.scaleOrdinal with fruit categories mapped to distinct colors, alongside a size legend using d3.scaleSqrt. The legends are rendered as SVG groups, with the color legend drawing rectangles and the size legend drawing circles. The code uses D3 v5’s selection.join pattern, custom legend components exported from separate modules, and explicit spacing and offset parameters to control layout within an SVG canvas.

AI-generated description
MIT Licensed

Similar vizzes