|
Given the pixel x,y cords how to get the index of the underling data? |
Posted by redblue on Mar-03-2017 05:36 |
|
Hi,
No doubt an easy question, but I can't seem to find the answer.
I have plotted a (xy) chart, and have the x,y cords from a mouse movement and I need to get hold of the index of the data that is closest to the x,y cords. Methods such as getXValue return the value, not the index. Thoughts?
Regards, |
Re: Given the pixel x,y cords how to get the index of the underling data? |
Posted by Peter Kwan on Mar-03-2017 22:50 |
|
Hi redblue,
The XYChart.getXValue returns the x value nearest to the mouse x coordinate. The Layer.getXIndexOf can then be used to obtain the index of that x-value in a particular layer. Because every layer can use different x-coordinates and different number of data points, so the indexes for different layers can be different. It is also possible for some layers to have no data point that corresponds to the given x-value, in which case the returned index will be -1 for that layer.
See:
http://www.advsofteng.com/doc/cdcpp.htm#Layer.getXIndexOf.htm
Regards
Peter Kwan |
|