Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Balanced annotation alignment

I would like to annotate a few peaks on a waveform graph, but I also want to achieve a certain balanced placement of the annotations. If I use the default alignment, alignment appears random and some annotations end up on top of one another at worst, on top of the plot line, or unbalanced at best. If I manually align them all with the same fixed values, the overall look is too rigid.

 

My goal is to have a balanced layout that uses the empty area above the plot line (or beside it, in the case of the highest peak, which doesn't leave room at the top of the graph for an annotation). Any ideas for how to achieve this goal?

0 Kudos
Message 1 of 7
(4,105 Views)

Related: is an accurate way to get the bounds of an annotation so I can make computations and move them around myself? If I call GetBounds on an XYPointAnnotation, it seems to return the bounds of the whole graph (using NIMS 2009).

0 Kudos
Message 2 of 7
(4,098 Views)

Hello Shawn,

 

You can use the CaptionAlignment method and the CaptionZOrder methods to set the positions for the annotations. If you want to get the size of the annotation box you can use:

Size rect = xyPointAnnotation1.ShapeSize;

 

Is this what you are looking to get? Or are you looking to get the size of the whole annotation including the arrow and caption?

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 3 of 7
(4,070 Views)

Sorry, I was unclear there. What I'm looking for bounds-wise is the caption bounds. The shape will always be on a point on the plot line, but I want to balance the captions in open space. To do think I think I need the caption bounds relative to the plot area.

0 Kudos
Message 4 of 7
(4,066 Views)

Hello Shawn,

 

Unfortunately there is not a method to get the caption bounds. A possible workaround would be to use a monospace font for the caption then get the string length and this way you would know how many pixels are being used and you should then be able to place it accordingling. Have a great day!

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 5 of 7
(4,042 Views)

Hi there,

Use the Graphics.MeasureString() method to get the size of caption.
And use the XYAnnotation.SetCaptionPosition() method to set the position of the caption.
Using these two you can calculate the bounds of the caption.

Regards,
Vijet Patankar
National Instruments

0 Kudos
Message 6 of 7
(4,035 Views)

Thanks, Adam and Vijet. I'm not sure if SetCaptionAlignment overrides CaptionAlignment or how the two properties interact, but this sounds like it could work.

0 Kudos
Message 7 of 7
(4,026 Views)