Multicolor Mouse Follower
✓ Published0🌍 Public
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
MIT Licensed