chartjs / chartjs/chartjs-plugin-datalabels

Click listener calls chart onClick function

Open
#219 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
920
Forks
507
PR merge metrics
No merged PRs in 30d

Description

Click listener invokes **two** onclick events:

1. one for data label
2. and the next one for chart `onClick` function.

Does anyone know how to prevent chart onClick event if data-label has been clicked? For now, they are just called both.

I have added `event.stopPropagation()` to data-labels click function but it didn't work

Data Labels plugin config:

```javascript
listeners: {
click: context => {
event.stopPropagation()
var name = context.chart.data.labels[context.dataIndex]
alert(name)
}
}
```

Chart configuration

```javascript
options: {
onClick: click_chart
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.