]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Pass the hover event to the onHover event handler (#3669)
authorJonathon Hill <jhill9693@gmail.com>
Sat, 3 Dec 2016 22:42:33 +0000 (17:42 -0500)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 3 Dec 2016 22:42:33 +0000 (17:42 -0500)
Pass the hover event to the onHover event handler

This makes the behavior of the `onHover` handler consistent with the `onClick` handler:

```
function(event, activeElements) {
    var chartInstance = this;
}
```

docs/01-Chart-Configuration.md
src/core/core.controller.js

index 55f7ddb6eb90dc389de40841fd31da56be54fde2..0b353d3a8bd57f44865c7538b059791ab7c919ca 100644 (file)
@@ -81,7 +81,7 @@ responsive | Boolean | true | Resizes the chart canvas when its container does.
 responsiveAnimationDuration | Number | 0 | Duration in milliseconds it takes to animate to new size after a resize event.
 maintainAspectRatio | Boolean | true | Maintain the original canvas aspect ratio `(width / height)` when resizing
 events | Array[String] | `["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"]` | Events that the chart should listen to for tooltips and hovering
-onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed an array of active elements
+onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed the event and an array of active elements
 legendCallback | Function | ` function (chart) { }` | Function to generate a legend. Receives the chart object to generate a legend from. Default implementation returns an HTML string.
 onResize | Function | null | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
 
@@ -310,7 +310,7 @@ Name | Type | Default | Description
 mode | String | 'nearest' | Sets which elements appear in the tooltip. See [Interaction Modes](#interaction-modes) for details
 intersect | Boolean | true | if true, the hover mode only applies when the mouse position intersects an item on the chart
 animationDuration | Number | 400 | Duration in milliseconds it takes to animate hover style changes
-onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed an array of active elements (bars, points, etc)
+onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed the event and an array of active elements (bars, points, etc)
 
 ### Interaction Modes
 When configuring interaction with the graph via hover or tooltips, a number of different modes are available.
index 1abc81075dadcc54f4c28014054c3d914ff64878..411021db485fe482f696c8ac7ee6e594639c54dc 100644 (file)
@@ -796,7 +796,7 @@ module.exports = function(Chart) {
 
                        // On Hover hook
                        if (hoverOptions.onHover) {
-                               hoverOptions.onHover.call(me, me.active);
+                               hoverOptions.onHover.call(me, e, me.active);
                        }
 
                        if (e.type === 'mouseup' || e.type === 'click') {