Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert coordinates of the ScarletGraph into coordinates of the screen

Hi,

I should to create on the graph 

XYPointAnnotation and to show dialogue of input of the text for annatation. For creation annotation I have coordinates. How to translate these coordinates into coordinates of the screen (correctly to display dialog).

For an example, 

I have there are two axes (time, temperature). I have coordinates (1min23sec, 35C). How to convert into coordinates of the screen?

P.S. Excuse for my bad English

0 Kudos
Message 1 of 3
(3,048 Views)
Hi,
You should be able to use the MapDataPoint method of the XYPlot class to accomplish what you are looking for.  Below is some quick example code that demonstrates how to use the function.  The code below returns the device coordinates for the point 5,5 on the graph.  One thing to keep in mind is that the point that this returns is relative to the location of the Graph or Chart object not to the whole form.  Hope this helps!

PointF point;
Rectangle yaxis = waveformGraph1.YAxes[0].GetBounds();
Rectangle xaxis = waveformGraph1.XAxes[0].GetBounds();
Rectangle rect = new Rectangle(xaxis.X, yaxis.Y, xaxis.Width, yaxis.Height);

point = waveformGraph1.Plots[0].MapDataPoint(rect, 5, 5);
Pat P.
Software Engineer
National Instruments
0 Kudos
Message 2 of 3
(3,030 Views)

Thanks. Works very well

0 Kudos
Message 3 of 3
(3,021 Views)