|
Group: Forum Members
Posts: 61,
Visits: 35
|
Hi,
So if I understand you right then you have a data table with all of the values what you have inserted on the graph.
If so then: I am not sure if that would be faster or not but You need to check the size of the graph, create a rectangle for restrictions of mouse click(if X and Y in the boundaries then handle the click event). Calculate the length of the X axis by pixel from the previous data.
Divide that number with the number of data points you display. You should get a decimal number which is bigger then 1 call this number indexHelper (if you have more data points to show on the graph then the size of the graph then that method wont work).
take the X coordinate of your mouse click event(minus the CO where your graph starts) then multiply it with the indexHelper that will be equal index.
You should get your datapoint from your dataTable with dataTable[index].
As I mentioned before that is just working if the number of your data points are less then the pixel length of the graph, plus if your data points are constant, your graph is not real time.
It is possible that the index wont be accurate(+1/-1) because of the rounding(the index need to be integer) but if thats really speeds up your program it might worth it.
Regards Daniel
|