Skip to main content
100%

Fork of Dispatching Events Example

✓ Published0🌍 Public
Ssriramvsharma
Last edited Oct 20, 2021
Created on Oct 20, 2021

This example demonstrates a custom D3 chart component that emits events to communicate changes. The Circle component renders an SVG circle that, when clicked, dispatches an `input` event with a new random radius value. The main script listens for this event and calls the circle’s update method, which uses a transition to animate the radius to the new size. The code uses D3’s `create` and `select` functions, along with the `dispatch` and `property` methods, to implement a reusable event-driven pattern. The circle’s cursor is set to a pointer to indicate interactivity.

AI-generated description

Click the circle to make it change size.

Trying to understand the pattern found in Observable: D3 Charts in terms of how one might adapt it so that chart instances can emit events.

Reference examples:

MIT Licensed

Similar vizzes