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 onClick to chartArea #6227

Merged
merged 2 commits into from
Oct 27, 2019
Merged

Limit onClick to chartArea #6227

merged 2 commits into from
Oct 27, 2019

Conversation

kurkle
Copy link
Member

@kurkle kurkle commented Apr 25, 2019

Closes: #6044

Demo

@etimberg etimberg requested a review from simonbrunel April 26, 2019 00:21
etimberg
etimberg previously approved these changes Apr 26, 2019
src/core/core.controller.js Outdated Show resolved Hide resolved
@nagix
Copy link
Contributor

nagix commented May 1, 2019

It may be better to handle click events in beforeEvent in the legend plugin and to return false because this change could break existing applications?

@kurkle
Copy link
Member Author

kurkle commented May 2, 2019

It may be better to handle click events in beforeEvent in the legend plugin and to return false because this change could break existing applications?

That would fire onClick on scales and could still break some applications.

@nagix
Copy link
Contributor

nagix commented May 2, 2019

Currently, click events are picked by legend's onClick and the chart-level onClick callbacks, but there is no callback in scales or other elements. onClick for the whole canvas has been available for long time, so I'm not sure it is breaking something.

On the other hand, click events on the legend cause a few problems as reported, I think this change (interception of click events by legend's onClick) is acceptable for most of users. How do you think?

Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably makes sense. Users can add their own onClick to the canvas fairly easily if that's what they want.

Not a main consideration, but this PR would improve usability of the zoom plugin chartjs/chartjs-plugin-zoom#205

@simonbrunel
Copy link
Member

I'm worry that there are existing implementations that listen for this click events and do hit test with scale elements or the title (e.g. open a "link"). I agree with @nagix, this is here since a very long time and I'm pretty sure it will break some projects.

@yusufozturk
Copy link

@kurkle @etimberg Thanks!

@kurkle kurkle deleted the onClick branch November 13, 2019 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onClick for inside the chart, not the whole canvas
6 participants