Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

21_color and size legends - General Update Pattern Special Cases

Public visualization

21_color and size legends - General Update Pattern Special Cases

0 stars0🌍 Public
Ssgzzhinde
Last edited Dec 23, 2020
Created on Dec 23, 2020

This example demonstrates the general update pattern for creating and updating color and size legends in D3.js. The color legend uses `d3.scaleOrdinal` to map categorical values like apple, lemon, lime, and orange to distinct colors, with circles and text labels arranged vertically. The size legend uses `d3.scaleSqrt` to map a numeric domain to circle radii, filtering ticks and reversing their order. Both legends are rendered as SVG groups within an SVG canvas, using selection, enter, update, and exit methods for dynamic updates.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed