chartjs-plugin-datalabels
chartjs-plugin-datalabels copied to clipboard
Click listener calls chart onClick function
Click listener invokes two onclick events:
- one for data label
- and the next one for chart
onClickfunction.
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:
listeners: {
click: context => {
event.stopPropagation()
var name = context.chart.data.labels[context.dataIndex]
alert(name)
}
}
Chart configuration
options: {
onClick: click_chart
}
@vasyl-shumskyi can you create a codepen that reproduces this behavior so it's easier for us to debug?
Can be reproduced here: https://jsfiddle.net/simonbrunel/rws67nkp/9/