liveBook · Manning

Mouse event

As explained in D3.js in Action, Third Edition

A mouseenter event is dispatched when a pointing device enters an element's area.

A mouse event lets a visualization respond when a pointing device enters or leaves an element. In D3, listeners receive the DOM event and the element’s bound datum. section 7.3.1

Make a tooltip keyboard-accessible

Mouse events alone exclude users who navigate with a keyboard. Make SVG circles focusable with tabindex, then pair mouseenter with focus and mouseleave with blur so the same tooltip works for both interaction methods. section 10.2.4

How D3.js in Action, Third Edition covers it

How deep it goes
Explains listener callbacks, bound data, target coordinates, transitions, and keyboard alternatives without detailing browser event internals.
Examples
Uses temperature tooltips on line-chart circles and cetacean tooltips on an accessible scatterplot.
What it assumes
Assumes D3 selections, SVG chart elements, and bound data while demonstrating event callbacks from working examples.
What you can do after
Build it from scratch by attaching D3 listeners that reveal, position, update, and hide chart tooltips.
How it connects
Connects DOM events with D3 selections, data binding, SVG elements, tooltips, focus events, and keyboard accessibility.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.