I'm adding annotations to a c# line chart. I'd like to change the text orientation but can't see any setting to allow this.
RectangleAnnotationannotation = new RectangleAnnotation();
annotation.AnchorDataPoint = chart1.Series[0].Points[x];
annotation.Text = "look an annotation";
annotation.ForeColor = Color.Black;
annotation.Font = new Font("Arial", 12); ;
annotation.LineWidth = 2;
chart1.Annotations.Add(annotation);
The annotation is added to the graph correctly and the rectangle and text run left to right. I want to orientate it to run up and down. Any suggestions on how to achieve this?
You cannot rotate annotations using the annotation library. You have to use
postpaint
orprepaint
. Here is a good example of how to use the post-paint event. Hope this helps. I'll include the code from the link below:}
EDIT: I just realized this example doesn't actually rotate the text. I know you have to use this tool so I will try to find an example using postpaint that rotates text.
EDIT 2: Aaah. Right here at SO. Basically you need to use the
e.Graphics.RotateTransform(270);
property (that line would rotate 270 degrees).