Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

getPointsAtEvent for Line charts doesn't give correct points

Open zeusdeux opened this issue 11 years ago • 2 comments

getPointsAtEvent for line charts always returns all the points at a label when the mouse enters pointHitDetectionRadius for any of the points at that label.

Shouldn't it just return the closest point based on the pointHitDetectionRadius?

If not, then how do I get which point the user clicked on?

Ty.

zeusdeux avatar Mar 03 '15 11:03 zeusdeux

I was a bit frustrated by this too. After some not-close-to-exhaustive-testing, I noticed that the array returned by that function appears to order the points from the left end of the pointHitDetectionRadius to the right. What I ended up doing for now is just grabbing the middle value in the array like so: var theFrames = theChart.getPointsAtEvent(evt); var theFrame = theFrames[Math.floor(theFrames.length / 2)];

JamesWilsonProjects avatar Mar 16 '15 05:03 JamesWilsonProjects

Hello, today I am closing all issues that are only affecting version 1 of Chart.js as WONTFIX.

If this issue does affect version 2 as well, I apologize for the error. Please create a test case against Chart.js 2 using on of the below websites and we will be happy to reopen the issue and update its classification:

  • http://jsbin.com/
  • http://jsfiddle.net/
  • http://codepen.io/pen/
  • Premade template: http://codepen.io/pen?template=JXVYzq

fulldecent avatar Jun 27 '16 17:06 fulldecent