Skip to main content
100%

D3 Color and Size Legends

✓ Published1🌍 Public
Ccaedcagt76@gmail.com
Last edited Jan 3, 2024
Created on Jan 3, 2024

This example demonstrates D3 color and size legends through an interactive fruit bowl visualization. Apple and lemon icons are rendered as SVG circles with red and yellow fills via `d3.scaleOrdinal`, while their radii vary between 50 and 25 pixels. The code uses a general update pattern with enter/merge/exit selections to animate changes in the fruit array over time, including removals and type substitutions. Static legends for color and size scales are created alongside the visualizations.

AI-generated description

Color and Size Legends

Topics covered:

  • Creating a color legend component
  • Encoding area using a square root scale
  • Computing ticks from size scale
  • Creating a size legend component
  • Tweaking the styles
MIT Licensed

Similar vizzes