-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Get point index from chart.getPointsAtEvent(e) #1283
Comments
I am currently solving this by looking up the index of the label but it is a bit hacky... |
We're trying to resolve this too, was thinking of comparing the mouse position to the X/Y co-ords of each dataset, however scaling seems to be an issue. |
Whoops I slightly misread the original question. Our problem was when there are multiple datasets within a bar chart, when you use myBarChart.getBarsAtEvent(e) in the mouse click event, unfortunately you get an array of all of the datasets underneath the pointer, not the specific bar you clicked. I hope you don't mind me posting our solution, because it might give you a clue as to how you can resolve the getPointsAtEvent issue as well :)
|
A small update - we've now carried out the above exercise for line charts too. We've assumed that each point is just a small rectangle, 10 x 10 pixels, and are detecting where the mouse pointer lies within those boundaries. Just substitute the $.grep statement from the code above as follows:
|
Thanks @tyrex1975 that was very helpful.. It would be great if in the future the activePoints came back with a selected boolean property so that we knew which ones were actually clicked at the point. Your work around worked great for me. Cheers! |
Good solution from @tyrex1975 |
Hello guys! i would like , if its possible current dataset selected, if you click on label, or bar graph, but it doesn't have value, in my case, i just want to click label, or region and know the axisX value. Is it posible??? Any suggestions? |
@tyrex1975 It's not working for me, an error
|
I made a workaround to get data from the clicked point;
|
Hi, I am looking to make my chart a little more interactive and I would like to get a
point
's index (of itsdataset
) with the following code:Anybody have a good solution for this?
The text was updated successfully, but these errors were encountered: