Skip to main content
100%

Multicolor Mouse Follower

✓ Published0🌍 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
MIT Licensed

Similar vizzes