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 Stackoverflow.com 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.

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.