From: Jonathon Hill Date: Sat, 3 Dec 2016 22:42:33 +0000 (-0500) Subject: Pass the hover event to the onHover event handler (#3669) X-Git-Tag: v2.5.0~1^2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=152ce9c9f83e3678aee663ee250d7cda06bb3b99;p=thirdparty%2FChart.js.git Pass the hover event to the onHover event handler (#3669) 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; } ``` --- diff --git a/docs/01-Chart-Configuration.md b/docs/01-Chart-Configuration.md index 55f7ddb6e..0b353d3a8 100644 --- a/docs/01-Chart-Configuration.md +++ b/docs/01-Chart-Configuration.md @@ -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. diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 1abc81075..411021db4 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -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') {