🌍 Public
Viewing a saved revision (read-only)
36536e95417c4840a68585dd4b6042cd
Multicolor Mouse Follower
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 descriptionBased 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