0

I use C# and Oxyplot.

I have a LineAnnotation to which I want to add a text.

So I have set Text Property for the LineAnnotation, but the text is vertical aligned.

How could I add a text (1..3 lines) to a LineAnnotation and that texts shows horizontally, so that users can read it ?

Not good :

enter image description here

What I would like:

enter image description here

LineAnnotation Markerline = new LineAnnotation();

Markerline.Color           = OxyColors.Blue;
Markerline.LineStyle       = LineStyle.Solid;
Markerline.StrokeThickness = 5;
Markerline.Type            = LineAnnotationType.Vertical;
Markerline.XAxisKey        = "x1";
Markerline.YAxisKey        = yAxisKey;  
Markerline.Tag             = "Marker";

Markerline.Text = "Hello World";  //how to display on top of Markerline horizontally ?
Spacewalker
  • 451
  • 1
  • 8
  • 29

2 Answers2

0

Just set the LineAnnotationType:

Markerline.Type            = LineAnnotationType.Horizontal;
Gordon Slysz
  • 1,083
  • 12
  • 23
0

You need to LineAnnotation.TextOrientation property. For example,

Markerline.TextOrientation = AnnotationTextOrientation.Horizontal;

In addition, you could also set the LineAnnotation.TextHorizontalAlingment Property to dictate on the position of Text with respect to the Line Annotation.

Markerline.TextHorizontalAlignment = HorizontalAlignment.Left;
Anu Viswan
  • 17,797
  • 2
  • 22
  • 51