SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.


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.