Pre loader

TextAnnotation with only X1,Y1 properties Resize behaviour

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


Here we use a TextAnnotation as follows

 var textAnnotation = new TextAnnotation
                                     Name = seriesAnnotationParameter.Name,
                                     Text = seriesAnnotationParameter.Text,
                                     ToolTip = seriesAnnotationParameter.ToolTip,
                                     XAxisId = XAxisId,
                                     YAxisId = YAxisId,
                                     X1 = seriesAnnotationParameter.X1,
                                     Y1 = seriesAnnotationParameter.Y1,
                                     HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                                     VerticalAnchorPoint = VerticalAnchorPoint.Center,
                                     TextAlignment = TextAlignment.Center,
                                     Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
                                     Opacity = 0.5,
                                     BorderThickness = new Thickness(1),
                                     CornerRadius = new CornerRadius(1),
                                     IsEditable = false

It works perfectly all-rite when you attach it to the chart the first time as in attached image TextAnnotation_Good.png. However, after zooming in or zooming out, the annotation is resized to undesirable sizes as in attached image TextAnnotation_Bad.png.

How to make TextAnnotation to resize itself based on the size of text inside it ?

This is a very special TextAnnotation centered around a x,y coordinate. There is never X2,Y2 for this use case.

  • You must to post comments

Hi Jerome,

The TextAnnotation only ever listens to X1, Y1 properties, and automatically calculates its size based on the text within it.

I haven’t tested this but I have something you can try out. Perhaps you can override this by setting TextAnnotation.Width, TextAnnotation.Height explicitly, e.g. during a layout pass, measure the contents and set the TextAnnotation size.

Alternatively, it is possible to set the BoxAnnotation.ControlTemplate to contain any UI, for instance, you could put a ViewBox and TextLabel in there. BoxAnnotation allows for finer control over size base on X1,Y1,X2,Y2.

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.