Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrow From Point

Solved!
Go to solution

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:current.PNG

 

Is there any way to draw an arrow between two points in the chart (relatively to the axes, not by pixels)?

 

 

0 Kudos
Message 1 of 3
(3,010 Views)
Solution
Accepted by topic author YEHUDIT

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.

~ Paul H
Download All
0 Kudos
Message 2 of 3
(2,983 Views)

Thank you very much!

It's exactly what I searched for!

0 Kudos
Message 3 of 3
(2,971 Views)