Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Color and Size Lengends

Public visualization

Viewing a saved revision (read-only)

a67cefac1328495f875116cc73dc39b1

Color and Size Lengends

0 stars0🌍 Public
Ffloresh
Last edited Nov 9, 2018
Created on Sep 29, 2018

This example demonstrates how to create separate legends for categorical color encoding and quantitative size encoding. The color legend uses an ordinal scale to map fruit names to distinct colors, while the size legend uses a square-root scale to map numeric values to circle radii. The reusable legend components (colorLegend and sizeLegend) are implemented as D3.js functions that append SVG groups, circles, and text elements, with tick marks generated from the scale's domain and ticks API.

AI-generated description