The LineArrowAnnotation
The LineArrowAnnotation draws an arrow from [X1, X2]
to [Y1, Y2]
coordinates:
Note
Examples of the Annotations usage can be found in the SciChart Android Examples Suite as well as on GitHub:
The LineArrowAnnotation class provides the stroke property which is used to define the line annotation color. It expects a PenStyle object. To learn more about Pens and Brushes and how to utilize them, please refer to the PenStyle, BrushStyle and FontStyle article.
Note
To learn more about Annotations in general - please see the Common Annotation Features article.
A LineArrowAnnotation is placed on a chart at the position determined by its [X1, Y1]
and [X2, Y2]
coordinates, which specifies the start and end of the arrow.
Those can be accessed via the following properties: x1, y1, x2, y2
The arrow's head is placed at [X2, Y2]
coordinates, its size is determined by the following properties:
Note
The xAxisId and yAxisId must be supplied if you have an axis with non-default Axis Ids, e.g. in multi-axis scenario.
Create a LineArrow Annotation
A LineArrowAnnotation can be added onto a chart using the following code:
// Assume a surface has been created and configured somewhere
// Create a LineArrow Annotation
final LineArrowAnnotation lineArrowAnnotation = new LineArrowAnnotation(getContext());
// Allow to interact with the annotation in run-time
lineArrowAnnotation.setIsEditable(true);
// in a multi-axis scenario, specify the XAxisId and YAxisId
lineArrowAnnotation.setXAxisId("TopAxisId");
lineArrowAnnotation.setYAxisId("LeftAxisId");
// Specify size for the arrow's head
lineArrowAnnotation.setHeadLength(4);
lineArrowAnnotation.setHeadWidth(8);
// Specify a desired position by setting coordinates
lineArrowAnnotation.setCoordinateMode(AnnotationCoordinateMode.RelativeY);
lineArrowAnnotation.setX1(40);
lineArrowAnnotation.setY1(0.8);
lineArrowAnnotation.setX2(100);
lineArrowAnnotation.setY2(0.2);
// Specify the stroke color for the annotation
lineArrowAnnotation.setStroke(new SolidPenStyle(Color.YELLOW, true, 2f, null));
// Add the annotation to the Annotations collection of the surface
surface.getAnnotations().add(lineArrowAnnotation);
Note
To learn more about other Annotation Types, available out of the box in SciChart, please find the comprehensive list in the Annotation APIs article.