Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Caption Annotation Possition

Solved!
Go to solution

Hello,

 

How can I get caption annotation possition ?

0 Kudos
Message 1 of 6
(4,854 Views)
Solution
Accepted by topic author xvc

Hello,

 

To get the location of the Annotation caption in graph coordinates, you need to get the XPosition and YPosition of the annotation, then use ScatterPlot.MapDataPoint to convert these positions to device coordinates and finally add the CaptionAlignment.XOffset and YOffset to these two values.  You can then go back to graph coordinates using InverseMapDataPoint. 

 

NickB

National Instruments 

Message 2 of 6
(4,844 Views)

Hello, I'v tried this but it doesn't work:

 

... 

xyPointAnnotation2.SetCaptionPosition(10, 3);

xyPointAnnotation2.SetPosition(20, 3); 

...

private void scatterGraph1_AfterDragAnnotationCaption(object sender, AfterDragXYAnnotationCaptionEventArgs e)

{

//e.XOffset = -292

//e.YOffset = 257

 

XYPointAnnotation annotation = e.Annotation as XYPointAnnotation;

 

//annotation.XPosition = 20

//annotation.YPosition = 3

 

PointF point = ((ScatterGraph)sender).Plots[0].MapDataPoint(scatterGraph1.PlotAreaBounds, annotation.XPosition, annotation.YPosition);

 

//PlotAreaBounds x = 29, y = 12, w = 437, h = 370

 

point.X += e.XOffset;

point.Y += e.YOffset;

 

//point.X = 28

 //point.Y = 527

 

 double x, y;

((ScatterGraph)sender).Plots[0].InverseMapDataPoint(scatterGraph1.PlotAreaBounds, point, out x, out y);

 

//x = -0.06

//y = -3.91

//should be 10, 3

}

 

Any idea why ... ?

Message Edited by xvc on 01-16-2009 06:42 AM
0 Kudos
Message 3 of 6
(4,830 Views)

I set Caption Alignment to None and it start work, but now SetCaptionPosition method doesn't work 😕

What I'm doing wrong ?

0 Kudos
Message 4 of 6
(4,821 Views)
OK, it works. Thank You very much !
Message Edited by xvc on 01-16-2009 08:28 AM
0 Kudos
Message 5 of 6
(4,816 Views)

Hello,

 

Sorry I haven't been able to reply a little earlier, I'm afraid I just got in to the office.  I'm glad to hear you've gotten things working though!

 

I also thought that I would add - because I had been a little sloppy in my response to your other post - that ScatterGraph.Bounds is not be the correct rect to use in this situation.  For results that are a little more accurate, you should use ScatterPlot.GetBounds().

 

Please let me know if you have any further questions!

 

NickB

National Instruments 

0 Kudos
Message 6 of 6
(4,808 Views)