In general case, the position of an SCIHorizontalLineAnnotation can be defined by the ISCIAnnotation.y1 value only, which will lead to full-width horizontal line at Y1 coordinate.
Despite the above, it is possible to specify X1 and X2 coordinates for the line ends, but it will work differently while combined with different SCIAlignment.
SCIHorizontalLineAnnotation.horizontalAlignment property can consume the following values:
SCIAlignment.SCIAlignment_Left - the X1 coordinate will be applied to the right end of a line. The line appears pinned to the left side.
SCIAlignment.SCIAlignment_Right - the X1 coordinate will be applied to the left end of a line. The line appears pinned to the right side.
// Assume a surface has been created and configured somewhere
id<ISCIChartSurface> surface;
// Create a HorizontalLine Annotation
SCIHorizontalLineAnnotation *horizontalLine = [SCIHorizontalLineAnnotation new];
// Allow to interact with the annotation in run-time
horizontalLine.isEditable = YES;
// In a multi-axis scenario, specify the XAxisId and YAxisId
horizontalLine.xAxisId = TopAxisId;
horizontalLine.yAxisId = RightAxisId;
// Specify a desired position by setting coordinates and mode
horizontalLine.coordinateMode = SCIAnnotationCoordinateMode_RelativeY;
horizontalLine.y1 = @(0.1);
// Specify the border color for the annotation
horizontalLine.stroke = [[SCISolidPenStyle alloc] initWithColorCode:0xFFFC9C29 thickness:2];
// Add the annotation to the Annotations collection of the surface
[self.surface.annotations add:horizontalLine];
// Assume a surface has been created and configured somewhere
let surface: ISCIChartSurface
// Create a HorizontalLine Annotation
let horizontalLine = SCIHorizontalLineAnnotation()
// Allow to interact with the annotation in run-time
horizontalLine.isEditable = true
// In a multi-axis scenario, specify the XAxisId and YAxisId
horizontalLine.xAxisId = TopAxisId
horizontalLine.yAxisId = RightAxisId
// Specify a desired position by setting coordinates
horizontalLine.coordinateMode = .relativeY
horizontalLine.set(y1: 0.1)
// Specify the stroke color for the annotation
horizontalLine.stroke = SCISolidPenStyle(colorCode: 0xFFFC9C29, thickness: 2)
// Add the annotation to the Annotations collection of the surface
self.surface.annotations.add(horizontalLine)
// Assume a surface has been created and configured somewhere
IISCIChartSurface surface;
// Create a HorizontalLine Annotation
var horizontalLine = new SCIHorizontalLineAnnotation
{
// Allow to interact with the annotation in run-time
IsEditable = true,
// In a multi-axis scenario, specify the XAxisId and YAxisId
XAxisId = TopAxisId,
YAxisId = RightAxisId,
// Specify a desired position by setting coordinates
CoordinateMode = SCIAnnotationCoordinateMode.RelativeY,
Y1Value = 0.1,
// Specify the stroke color for the annotation
Stroke = new SCISolidPenStyle(0xFFFC9C29, 2),
};
// Add the annotation to the Annotations collection of the surface
Surface.Annotations.Add(horizontalLine);
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.
let annotationLabel = SCIAnnotationLabel()
annotationLabel.labelPlacement = .axis
horizontalLine.annotationLabels.add(annotationLabel)
var annotationLabel = new SCIAnnotationLabel();
annotationLabel.LabelPlacement = SCILabelPlacement.Axis;
horizontalLine.AnnotationLabels.Add(annotationLabel);
// Declare custom ISCIFormattedValueProvider
class AnnotationValueProvider : ISCIFormattedValueProvider
{
public override IISCIString FormatValueWithAxisInfo(SCIAxisInfo axisInfo)
{
return axisInfo != null ? $“$ {axisInfo.AxisFormattedDataValue} $”.ToSciString() : null;
}
}
…
var horizontalLine = new SCIHorizontalLineAnnotation();
horizontalLine.X1Value = 10;
horizontalLine.Y1Value = 34.512;
horizontalLine.IsEditable = true;
horizontalLine.HorizontalAlignment = SCIAlignment.Right;
// Provide custom ISCIFormattedValueProvider for the annotation
horizontalLine.FormattedLabelValueProvider = new AnnotationValueProvider();
var axisAnnotationLabel = new SCIAnnotationLabel();
axisAnnotationLabel.LabelPlacement = SCILabelPlacement.Axis;
horizontalLine.AnnotationLabels.Add(axisAnnotationLabel);
The result will be the following:
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.