Search Results for

    Show / Hide Table of Contents

    The LineArrowAnnotation

    The LineArrowAnnotation draws an arrow from [X1, X2] to [Y1, Y2] coordinates:

    Line Arrow Annotation

    Note

    Examples of the Annotations usage can be found in the SciChart Android Examples Suite as well as on GitHub:

    • Native Android Chart Annotations Example

    • Native Android Chart Interactive Annotations Example

    • Xamarin Android Chart Annotations Example

    • Xamarin Android Chart Interactive Annotations Example

    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:

    • setHeadLength(float headLength)
    • setHeadWidth(float headWidth)
    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:

    • Java
    • Java with Builders API
    • Kotlin
    // 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);
    
    // Assume a surface has been created and configured somewhere
    // Create a Line Annotation
    final LineArrowAnnotation lineArrowAnnotation = sciChartBuilder.newLineArrowAnnotation()
            // Allow to interact with the annotation in run-time
            .withIsEditable(true)
            // In a multi-axis scenario, specify the XAxisId and YAxisId
            .withXAxisId("TopAxisId")
            .withYAxisId("LeftAxisId")
            // Specify size for the arrow's head
            .withArrowHeadLength(4)
            .withArrowHeadWidth(8)
            // Specify a desired position by setting coordinates
            .withCoordinateMode(AnnotationCoordinateMode.RelativeY)
            .withPosition(40, 0.8, 100, 0.2)
            // Specify the thickness and the stroke color for the annotation
            .withStroke(2f, Color.YELLOW)
            .build();
    
    // Add the annotation to the Annotations collection of the surface
    surface.getAnnotations().add(lineArrowAnnotation);
    
    // Assume a surface has been created and configured somewhere
    // Create a LineArrow Annotation
    val lineArrowAnnotation = LineArrowAnnotation(context)
    
    // Allow to interact with the annotation in run-time
    lineArrowAnnotation.setIsEditable(true)
    
    // in a multi-axis scenario, specify the XAxisId and YAxisId
    lineArrowAnnotation.xAxisId = "TopAxisId"
    lineArrowAnnotation.yAxisId = "LeftAxisId"
    
    // Specify size for the arrow's head
    lineArrowAnnotation.headLength = 4f
    lineArrowAnnotation.headWidth = 8f
    
    // Specify a desired position by setting coordinates
    lineArrowAnnotation.coordinateMode = AnnotationCoordinateMode.RelativeY
    lineArrowAnnotation.x1 = 40
    lineArrowAnnotation.y1 = 0.8
    lineArrowAnnotation.x2 = 100
    lineArrowAnnotation.y2 = 0.2
    
    // Specify the stroke color for the annotation
    lineArrowAnnotation.stroke =
        SolidPenStyle(Color.YELLOW, true, 2f, null)
    
    // Add the annotation to the Annotations collection of the surface
    surface.annotations.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.

    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml