SciChart iOS v2.x API > Annotations API > Combining Multiple Annotations
Combining Multiple Annotations

You can add multiple annotations at the same time with AnnotationCollection. This collection exists on the SciChartSurface.annotations property and you can either add annotations to it directly, or create a whole new collection to attach.

As soon as annotations are added to the collection, they will be drawn on the chart.

Examples for the Annotations API can be found in the SciChart iOS Examples Suite.

SCIAnnotationCollection *annotationCollection = [SCIAnnotationCollection new];
SCITextAnnotation * textAnnotation = [[SCITextAnnotation alloc] init];
textAnnotation.coordinateMode = coordMode;
textAnnotation.x1 = SCIGeneric(x);
textAnnotation.y1 = SCIGeneric(y);
textAnnotation.horizontalAnchorPoint = horizontalAnchorPoint;
textAnnotation.verticalAnchorPoint = verticalAnchorPoint;
textAnnotation.text = text;
textAnnotation.style.textStyle = textStyle;
textAnnotation.style.textColor = [UIColor fromARGBColorCode:color];
textAnnotation.style.backgroundColor = [UIColor clearColor];
[annotationCollection add:textAnnotation];
SCILineAnnotation * lineAnnotationRelative = [SCILineAnnotation new];
lineAnnotationRelative.coordinateMode = SCIAnnotationCoordinate_Absolute;
lineAnnotationRelative.x1 = SCIGeneric(x1);
lineAnnotationRelative.y1 = SCIGeneric(y1);
lineAnnotationRelative.x2 = SCIGeneric(x2);
lineAnnotationRelative.y2 = SCIGeneric(y2);
lineAnnotationRelative.style.linePen = [[SCISolidPenStyle alloc] initWithColorCode:color withThickness:strokeThickness];
[annotationCollection add:lineAnnotationRelative];

surface.annotations = annotationCollection ;
let annotationGroup = SCIAnnotationCollection()
let textAnnotation = SCITextAnnotation()
textAnnotation.coordinateMode = coordMode;
textAnnotation.x1 = SCIGeneric(x);
textAnnotation.y1 = SCIGeneric(y);
textAnnotation.horizontalAnchorPoint = horizontalAnchorPoint;
textAnnotation.verticalAnchorPoint = verticalAnchorPoint;
textAnnotation.text = text;
textAnnotation.style.textStyle = textStyle;
textAnnotation.style.textColor = UIColor.fromARGBColorCode(color);
textAnnotation.style.backgroundColor = UIColor.clear
annotations.add(textAnnotation);
let lineAnnotationRelative = SCILineAnnotation();
lineAnnotationRelative.coordinateMode = .absolute;
lineAnnotationRelative.x1 = SCIGeneric(x1);
lineAnnotationRelative.y1 = SCIGeneric(y1);
lineAnnotationRelative.x2 = SCIGeneric(x2);
lineAnnotationRelative.y2 = SCIGeneric(y2);
lineAnnotationRelative.style.linePen = SCISolidPenStyle.init(colorCode:color, withThickness:Float(strokeThickness));
annotations.add(lineAnnotationRelative);

surface.annotations = annotationGroup

See Also