04-20-2017 06:51 AM
I want to draw an arrow from a specific point in the graph (I have the position of the point relatively to the axes), in fixed length, with specific angle.
Currently, I found option to draw only arrow from label to point (in PointAnnotation):
PointAnnotation point = new PointAnnotation(); point.HorizontalPosition = arrow.Position.X; point.VerticalPosition = arrow.Position.Y; point.TargetSize = new Size(0, 0); point.ArrowBrush = new SolidColorBrush(arrow.Color); point.ArrowVisibility = System.Windows.Visibility.Visible; point.ArrowHeadShape = PointShape.OutwardTriangle; point.LabelAlignment = new AnnotationLabelAlignment(BoundsAlignment.None, 100, 100);
I got this as a result:
Is there any way to draw an arrow between two points in the chart (relatively to the axes, not by pixels)?
Solved! Go to Solution.
04-20-2017 01:56 PM
Using code to translate between data and screen coordinates, it is possible to calculate the required position to draw a line between two data points with a PointAnnotation. I have included the relevant code below (see the attached example for more details):
Point screenStart = graph.DataToScreen( plot, new[] { dataStart.X, dataStart.Y } );
Point screenEnd = graph.DataToScreen( plot, new[] { dataEnd.X, dataEnd.Y } );
point.HorizontalPosition = dataStart.X;
point.VerticalPosition = dataStart.Y;
point.LabelAlignment = new AnnotationLabelAlignment(
BoundsAlignment.None,
screenEnd.X - screenStart.X,
screenEnd.Y - screenStart.Y );
If this proves insufficient, you could implement a new IRenderable type (which is what the point annotation derives from), to perform custom rendering logic.
04-22-2017 04:31 PM
Thank you very much!
It's exactly what I searched for!