01-15-2009 07:06 AM
01-15-2009 11:10 AM
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
01-16-2009 06:42 AM - edited 01-16-2009 06:42 AM
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 = 527double 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 ... ?
01-16-2009 07:49 AM
I set Caption Alignment to None and it start work, but now SetCaptionPosition method doesn't work 😕
What I'm doing wrong ?
01-16-2009 08:21 AM - edited 01-16-2009 08:28 AM
01-16-2009 08:28 AM
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