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

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.