The LineArrowAnnotation allows to draw an arrow from X1,Y1 to X2,Y2 position:

LineAnnotation Features

Please refer to the Common Annotation Features to learn more about the ones inherited from the base class. The Stroke color can be applied via the setStroke() method, which expects a PenStyle object. Please refer to the Styling and Theming section to learn more about pens and brushes in SciChart.

Size of the arrow's head can be changed via the setHeadLength(), setHeadWidth() methods.

Position LineAnnotation

LineArrowAnnotation is placed on a chart at the position determined by its X1,Y1 and X2,Y2 coordinates, which specify the two line ends. It can be set via the setX1(), setY1()setX2()setY2() methods. The arrow's head is placed at X2,Y2.

In a multi-axis scenario, or if you changed the Ids of your axes, both XAxisId and YAxisId must be set. This can be done via the setAxisId(), setYAxisId() methods.

Create LineAnnotation

A LineArrowAnnotation can be added onto a chart using the following code:

Copy Code
// assume the surface has been created and configured before
ISciChartSurface surface;

// create an LineAnnotation
LineArrowAnnotation lineArrowAnnotation = new LineArrowAnnotation(getActivity());

// specify a PenStyle for the Stroke
lineArrowAnnotation.setStroke(new SolidPenStyle(0xFF0000FF, true, 4, null));

// allow to interact with the annotation in run-time

// in a multi-axis scenario, specify the XAxisId and YAxisId

// specify size for the arrow's head

// specify a desired position by setting coordinates
// the arrow's head is located at X2,Y2

// add the annotation to the Annotations collection of the surface
Collections.addAll(surface.getAnnotations(), lineArrowAnnotation);

Also, a LineArrowAnnotation can be created using Chart Builders:

Copy Code
LineAnnotation lineAnnotation = sciChartBuilder.newLineAnnotation()
        .withPosition(1d, 4d, 2d, 6d)
        .withStroke(2f, 0xFF555555)

To learn more about other annotation types, available out of the box in SciChart, please find the comprehensive list in the What Is an Annotation article.

See Also