Get X axes value from the cursor coodinate.

Sep 2, 2009 at 3:38 PM

Hi Mikhail,

I would like to implement a feature using the cursor coordinate on the chart to get the X axes value of the current position of the cursor when the mouse left button is down.

The cursor actually displays the correct value, but I would not find how to get the same value through his properties.

Lets says that when I click the first time the cursor is on postion 20 (value of the x axes)

The second time I click the cursor is on position 60 (value of the x axes)

Once that I have capture these two values I could use it to display the difference between this two points e.g.  60 – 20 = 40 and dispaly this value in another label in my form.

I Implemented the MouseLeftButtonDown event on the Chart Plotter then I access my cursor coordinate position but the X and Y values are screen coordinates and I need to have the X axes value, the same value the cursor already display in the box. (e.g. cursorCoordiante.Position.X is a screen coordinate)

I check your sample Line Test Sample where you implemented the DataFollowChart but the problem I got is that I plot all my LineGraph at run time, I could have one or more line graphs and they all share the same x values.

The cursor coordinate shows always a box with the current value on the X axes and the Y axes, if I can access the value on that box I think I will be ok but I could not find how.

I will appreciate if you can point me how I can achieve this.

Regards,

Pedro

 

Editor
Oct 14, 2009 at 4:36 PM

Hi Pedro,

Sorry for being late with the answer,

So, the solution is:

1) subscribe for MouseDown (for example) event of plotter.CentralGrid or plotter.MainCanvas or Plotter2D.ViewportPanel - these are panels that are situated right in the visible area, so mouse coordinates you got from them, will be correct.

2) once you have a point where user clicked by the mouse, translate it into viewport coordinate system by using plotter.Viewport.Transform class, which has methods to translate points from one coordinate system to another (you can read a little bit more about it in our wiki at http://microsoft.cs.msu.su/personal/thecentury/Public%20Documents/Wiki/D3.html#Viewport2D

 

That's all.

Hope this helps,

Regards,

Mikhail.