Pointer events
Supported events
Pointer events are supported on the containing Chart
element and on most child elements. In the case of data series, the handlers are passed on to the child data points. The following handler props can be declared:
- onPointerDown
- onPointerMove
- onPointerUp
- onPointerCancel
- onGotPointerCapture
- onLostPointerCapture
- onPointerEnter
- onPointerLeave
- onPointerOver
- onPointerOut
Check out this article to learn more about the mental model behind pointer events. MDN is the best place to get detailed info on when each event will fire. Finally, the React docs are always worth a look.
Event data
Hypocube re-maps the Event passed to the handler so that the relevent coordinates on the Cartesian data scales are available. To see this, try clicking on the bars in the chart below - and have a look at your console.
Notice that the elementPosition
corresponds to the real position of the data point. Similarly, the coordinates of pointerPosition
correspond to the event position on the Cartesian scale.
In detail, the ChartEvent
object has the following properties: