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

Click listener calls chart onClick function #219

Open
vasyl-shumskyi opened this issue Feb 5, 2021 · 2 comments
Open

Click listener calls chart onClick function #219

vasyl-shumskyi opened this issue Feb 5, 2021 · 2 comments

Comments

@vasyl-shumskyi
Copy link

vasyl-shumskyi commented Feb 5, 2021

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:

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

Chart configuration

options: {
            onClick: click_chart 
}
@simonbrunel
Copy link
Member

@vasyl-shumskyi can you create a codepen that reproduces this behavior so it's easier for us to debug?

@simonbrunel
Copy link
Member

Can be reproduced here: https://jsfiddle.net/simonbrunel/rws67nkp/9/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants