Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color and Size Legend

Public visualization

Color and Size Legend

0 stars0🌍 Public
Jjeelong
Last edited Jun 24, 2020
Created on Jun 21, 2020

Two custom legend components demonstrate how to encode data through color and size. The color legend uses a D3 ordinal scale with four fruit categories, while the size legend uses a square-root scale with five tick values. Both legends are rendered as SVG groups using reusable functions that handle enter/update/exit selections. The code uses `d3.scaleOrdinal`, `d3.scaleSqrt`, and selection methods like `merge` and `attr` to position circles and text labels with consistent spacing.

AI-generated description

React Starter code.

Comments

Sign in to join the discussion.

MIT Licensed