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
- EJansen asked 9 years ago
- You must login to post comments
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.
- Andrew Burnett-Thompson answered 9 years ago
- Hi Andrew, This works great. Thanks, Egbert
- You must login to post comments
Please login first to submit.