DOM - Event Listener in D3.
Special operators called event handlers respond to user input and enable interaction.
For consistency with other functional operators, the callback receives the data and index as arguments (d, i), allowing data-driven interaction.
The targeted node is this, and the current event is d3.event. Listeners may coexist on elements through namespaces (e.g., “click.foo”).
D3’s focus on transformations simplifies the specification of scene changes in response to user events; the semantics are the same as initialization.