Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Annotation placement

I'm having trouble placing an annotation on my scattergraph. I am using a scattergraph as my plotting control but most of the time I do not have a plot up and I want to place annotations on various parts of the graph.

I can't figure out how to place them.

Scott
0 Kudos
Message 1 of 10
(5,202 Views)
In the Measurement Studio .NET graphs, annotations are associated with axes. This is different from the behavior in the Measurement Studio ActiveX graph, where annotations were associated with plots. You can then position point annotations via the XPosition/YPosition properties and range annotations via the XRange/YRange properties. These positions are in data coordinates and how they map to screen coordinates is determined by the axes that are associated with the annotations (via the XAxis/YAxis properties).

What type of annotation are you adding? A point annotation or a range annotation? What are you doing to position the annotations and how does that behave vs. how you want it to behave?

- Elton
0 Kudos
Message 2 of 10
(5,187 Views)
Thanks for the reply, Elton.

--What type of annotation are you adding? A point annotation or a range annotation? What are you doing to position the
--annotations and how does that behave vs. how you want it to behave?

You are asking all the same questions I want to know the answer to. Do I want to use a point anno or a range anno??

The user wants to put up annotations (single head arrow with caption) on the control anywhere with out respect to a plot or anything. Whereever the user clicks and drags is where I want to let him put the annotation on the control. Is there a way to do this? I don't know how to position the annotation.

Scott
0 Kudos
Message 3 of 10
(5,183 Views)
You can see an example of the point annotation under ..\MeasurementStudio\DotNET\Examples\UI\Graph\SimpleAnnotations. This allows you to highlight a single data point. Range annotations allow you to highlight an entire region of data.

Sounds like you need a point annotation. Check out the above mentioned example on how to set this up. This just involves using the SetPosition() method on the point annotation.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 4 of 10
(5,172 Views)
Yea, I've been through that example. SetPosition allows you to place the arrowhead but not the caption. I need to position both anywhere on the graph. I just need some insight as to how to place both ends of the annotation. I have burned too many hours trying to position it and I was hoping someone out there had some insight. Thanks for chiming in.

Scott
0 Kudos
Message 5 of 10
(5,166 Views)
The position of the caption is configured by the CaptionAlignment property. There are three things that you specify in the CaptionAlignment property to position the caption: the alignment, the X offset, and the Y offset. The alignment lets you specify different positions within the plot area that the caption can be aligned to. If you want the caption to be positioned relative to the point rather than the plot area bounds, specify None. The X and Y offsets are the offsets in screen coordinates that the caption will be aligned to relative to the alignment position.

For example, if you always wanted the caption to be 25 pixels to the right of the point and 50 pixels above the point, you would specify None for the alignment, 25 for the X offset, and -50 for the Y offset. If you wanted the caption to always be in the upper right hand corner of the plot area, you would specify TopRight for the alignment, and 0 for the X and Y offsets.

Hope this helps.

- Elton
0 Kudos
Message 6 of 10
(5,159 Views)
Elton,

I'll give that a try. Thanks a mil.

Scott O'
0 Kudos
Message 7 of 10
(5,159 Views)
No problem. Please post a reply to let us know how it worked out after you try it. Thanks.

- Elton
0 Kudos
Message 8 of 10
(5,151 Views)

Hello,

 

sorry for replying to this old post, but I have a problem regarding exactly this issue.

I use XYRangeAnnotations in a WaveFormGraph to specify some (many) regions.

Each annotation has a caption (should act as label for the annotation) with BoundsAlignment.None.

If the plot is dragged so that the annotation gets clipped, the caption moves away from the annotation (seems that it tries to stay within the plotarea) unless the annotation is completely dragged out of the plotarea. Then the caption also begins moving out of the plotarea.

 

Even if this might be the desired behavior, I'd like to switch this off! The caption should stay fixed to the desired position relative to its annotation, otherwise I can't figure out which caption belongs to which annotation in some situations. A BoundsAlignment which refers to the annotation instead of the plotarea would be helpful.

 

Best Regards,

Alex

0 Kudos
Message 9 of 10
(4,326 Views)

Hey Alex,

This is an interesting problem. There is a tricky way to tackle this. Use the XYRangeAnnotation.SetCaptionPosition(double, double) to set a fixed position for the Caption. Do this in the XAxisRangeChanged and YAxisRangeChanged events on the WaveformGraph. This will keep the caption always relative to what it is pointing to.

 

Here is the sample code showing the same.

private void waveformGraph2_XAxisRangeChanged(object sender, NationalInstruments.UI.XAxisEventArgs e)
{
// Note here the value 5 is measured in data coordinates (not in pixels).
xyRangeAnnotation1.SetCaptionPosition(5, 5);
}

private void waveformGraph2_YAxisRangeChanged(object sender, NationalInstruments.UI.YAxisEventArgs e)
{
xyRangeAnnotation1.SetCaptionPosition(5, 5);
}

 

Hope this helps.
Message 10 of 10
(4,319 Views)