Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Multicolor Mouse Follower

Public visualization

Viewing a saved revision (read-only)

7b19e5349cc343188bdee7b03f158433

Multicolor Mouse Follower

0 stars0🌍 Public
CCurran Kelleher
Last edited Jan 12, 2023
Created on Jan 12, 2023

This example demonstrates how a visualization can maintain multiple independent pieces of state that respond to different user interactions. A circle follows the mouse's horizontal and vertical position through mousemove events, while clicking randomly changes its fill color and opacity using a custom color generator. The visualization uses D3.js version 7 with the join pattern to bind SVG elements, separating the state management logic from the rendering function that updates the circle's attributes.

AI-generated description

Based on original work by Spencer, this example shows how you can have multiple independent pieces of state that respond to different interactions:

  • Moving the mouse moves the circle
  • Clicking changes color