Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit onHover to chartArea #8794

Merged
merged 1 commit into from Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/configuration/interactions.md
Expand Up @@ -18,8 +18,8 @@ Namespace: `options`
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `events` | `string[]` | `['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']` | The `events` option defines the browser events that the chart should listen to for. Each of these events trigger hover and are passed to plugins. [more...](#event-option)
| `onHover` | `function` | `null` | Called when any of the events fire. Passed the event, an array of active elements (bars, points, etc), and the chart.
| `onClick` | `function` | `null` | Called if the event is of type `'mouseup'` or `'click'`. Passed the event, an array of active elements, and the chart.
| `onHover` | `function` | `null` | Called when any of the events fire over chartArea. Passed the event, an array of active elements (bars, points, etc), and the chart.
| `onClick` | `function` | `null` | Called if the event is of type `'mouseup'`, `'click'` or '`'contextmenu'` over chartArea. Passed the event, an array of active elements, and the chart.

### Event Option

Expand Down
8 changes: 4 additions & 4 deletions src/core/core.controller.js
Expand Up @@ -1108,11 +1108,11 @@ class Chart {
// This prevents recursion if the handler calls chart.update()
me._lastEvent = null;

// Invoke onHover hook
callCallback(options.onHover, [e, active, me], me);
if (_isPointInArea(e, me.chartArea, me._minPadding)) {
// Invoke onHover hook
callCallback(options.onHover, [e, active, me], me);

if (e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu') {
if (_isPointInArea(e, me.chartArea, me._minPadding)) {
if (e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu') {
callCallback(options.onClick, [e, active, me], me);
}
}
Expand Down