Pre loader

Center textannotation in chart

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

0
0

Hi,

I would like to position a textannotation in the middle of the chartarea (horizontal and vertical).

I’m using the following code, but is doesn’t work:

TextAnnotation textAnnotation = new TextAnnotation();
textAnnotation.Text = "Initializing";
textAnnotation.X1 = (double)xAxis.VisibleRange.Min;
textAnnotation.X2 = (double)xAxis.VisibleRange.Max;
textAnnotation.Width = (double)textAnnotation.X2 - (double)textAnnotation.X1;
textAnnotation.HorizontalAlignment = HorizontalAlignment.Center;
textAnnotation.HorizontalContentAlignment = HorizontalAlignment.Center;
textAnnotation.Y1 = ((double)yAxes[0].VisibleRange.Max + (double)yAxes[0].VisibleRange.Min) / 2;
textAnnotation.XAxisId = xAxis.Id;
textAnnotation.YAxisId = yAxes[0].Id;
textAnnotation.BorderBrush = Brushes.Black;
textAnnotation.BorderThickness = new Thickness(1);
this.Annotations.Add(textAnnotation);

Thanks,
Egbert

  • You must to post comments
0
0

We actually support centre placement of text out of the box. Can you try setting CoordinateMode.Relative then set HorizontalAnchor/VerticalAnchorPoint to central and finally X1,Y1 only to 0.5.

Please see the Annotations Are Easy article for a thorough definition of the properties on Annotations.

  • EJansen
    Hi Andrew, This works great. Thanks, Egbert
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies