Skip to main content
Public

Share visualization

Loading preview…

Interactive Color Legend

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Interactive Color Legend

9
CCurran Kelleher
Last edited Oct 9, 2025
Created on Mar 13, 2023

This example visualizes the Iris Dataset as a scatter plot, mapping sepal length against petal length and coloring points by species using a categorical color scale. An interactive color legend allows hovering over species names to highlight corresponding marks while dimming others. The implementation leverages d3.scaleOrdinal, d3.scaleLinear, d3.extent, and d3.selection’s .join() method for efficient DOM updates. Axes and legends are composed as reusable functions, with hover interactions managed through explicit event handlers on legend ticks.

AI-generated description

A scatter plot of the Iris Dataset with a color legend.

Hover on the color legend to highlight the marks that match!

See also:

Comments

Sign in to join the discussion.

MIT Licensed