Dispatching Events Example
A circle rendered as an SVG element changes its radius in response to clicks, demonstrating how chart instances can emit and handle custom events. Clicking the circle triggers a click handler in the Circle component, which dispatches an `input` event with a random value and a `detail` property. The main script listens for this event using D3’s `select().on()`, reads the radius from `event.target.value`, and calls the `update()` method to animate the radius via a D3 transition. The example uses `d3.create`, `d3.select`, and `transition.attr`, based on the Observable chart pattern.
AI-generated descriptionClick 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: