Skip to main content
๐ŸŒ Public

Share visualization

Send this visualization to others.

Color and Size Legends

Public visualization

Color and Size Legends

0 stars0๐ŸŒ Public
MMukund Khandelwal
Last edited Oct 2, 2018
Created on Sep 30, 2018

This example demonstrates reusable legend components for both categorical color scales and quantitative size scales. It renders four fruit categories (apple, lemon, lime, orange) using a d3.scaleOrdinal with distinct colors, alongside a d3.scaleSqrt size legend with five ticks. Both legends are built with SVG groups, circles, and text elements, using d3 selections and the .call() method to invoke the custom colorLegend and sizeLegend functions. The size legend filters out zero values and reverses tick order for visual clarity.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed