SChartAnnotation Class Reference

Inherits from UIView
Declared in SChartAnnotation.h
Availability Premium
Related samples

Overview

An SChartAnnotation is a UIView that can be displayed on a chart - maintaining aspect ratio at all times and position in accordance with the panning of the data range (see below).

There are several predefined annotations for convenience - these can be created using the methods below and are bands, lines and text.

An SChartAnnotation is fixed to a single point on the chart which means that it will pan but will remain a fixed size regardless of zoom level. If you would like to annotate an area that will scale as the data range is zoomed use SChartAnnotationZooming, which is anchored between two limits on either axis.

An annotation can be attached to one of the x axes, and one of the y-axes in the chart. This is done using the xAxis and yAxis properties on the annotation. If an annotation is attached to an axis, the position of the annotation on the chart will correspond to its value on that axis. The position of the annotation on the x axis will correspond to xValue and its position on the y axis will correspond to yValue.

More information about using SChartAnnotation can be found in the user guide

Warning: This feature isn’t currently supported on radial charts.

Properties

label

If this is a text annotation, this property is an accessor for the text label. Otherwise it returns nil.

@property (nonatomic, retain, nullable) UILabel *label

Declared In

SChartAnnotation.h

position

Sets how annotations should be drawn relative to your chart data.

@property (nonatomic) SChartAnnotationPosition position

Discussion

  • SChartAnnotationAboveData: Configures the annotation to be drawn in front of your chart data.
  • SChartAnnotationBelowData: Configures the annotation to be drawn underneath your chart data.

In most cases, we will want the annotation to be drawn in front of the chart data, and so by default this is set to SChartAnnotationAboveData.

Declared In

SChartAnnotation.h

xAxis

The x axis that the annotation is attached to.

@property (nonatomic, assign, nullable) SChartAxis *xAxis

Discussion

A nil value will cause the view to be displayed at the midpoint of the width of the chart plot area.

Declared In

SChartAnnotation.h

xValue

The value on the given xAxis that the annotation is going to be anchored to.

@property (nonatomic, retain, nullable) id xValue

Discussion

A nil value will cause the view to be displayed at the midpoint of the width of the chart plot area.

Declared In

SChartAnnotation.h

yAxis

The y axis that the annotation is attached to.

@property (nonatomic, assign, nullable) SChartAxis *yAxis

Discussion

A nil value will cause the view to be displayed at the midpoint of the height of the chart plot area.

Declared In

SChartAnnotation.h

yValue

The value on the given yAxis that the annotation is going to be anchored to.

@property (nonatomic, retain, nullable) id yValue

Discussion

A nil value will cause the view to be displayed at the midpoint of the height of the chart plot area.

Declared In

SChartAnnotation.h

Class Methods

annotationWithText:andFont:withXAxis:andYAxis:atXPosition:andYPosition:withTextColor:withBackgroundColor:

Creates an annotation based on a UILabel with the given string at the given x and y axis positions.

+ (SChartAnnotation *)annotationWithText:(NSString *)text andFont:(UIFont *)font withXAxis:(SChartAxis *)xAxis andYAxis:(SChartAxis *)yAxis atXPosition:(id)xValue andYPosition:(id)yValue withTextColor:(UIColor *)textColor withBackgroundColor:(UIColor *)backgroundColor

Declared In

SChartAnnotation.h

horizontalBandAtPosition:andMaxY:withXAxis:andYAxis:withColor:

Creates a horizontal band that spans the given range on the y axis and spans the whole width of the x axis.

+ (SChartAnnotationZooming *)horizontalBandAtPosition:(id)minY andMaxY:(id)maxY withXAxis:(SChartAxis *)xAxis andYAxis:(SChartAxis *)yAxis withColor:(UIColor *)color

Declared In

SChartAnnotation.h

horizontalLineAtPosition:withXAxis:andYAxis:withWidth:withColor:

Creates a horizontal line at the given y position that spans the whole width of the x axis.

+ (SChartAnnotationZooming *)horizontalLineAtPosition:(id)yValue withXAxis:(SChartAxis *)xAxis andYAxis:(SChartAxis *)yAxis withWidth:(CGFloat)width withColor:(UIColor *)color

Declared In

SChartAnnotation.h

verticalBandAtPosition:andMaxX:withXAxis:andYAxis:withColor:

Creates a vertical band that spans the given range on the x axis and spans the whole height of the y axis.

+ (SChartAnnotationZooming *)verticalBandAtPosition:(id)minX andMaxX:(id)maxX withXAxis:(SChartAxis *)xAxis andYAxis:(SChartAxis *)yAxis withColor:(UIColor *)color

Declared In

SChartAnnotation.h

verticalLineAtPosition:withXAxis:andYAxis:withWidth:withColor:

Creates a vertical line at the given x position that spans the whole height of the y axis.

+ (SChartAnnotationZooming *)verticalLineAtPosition:(id)xValue withXAxis:(SChartAxis *)xAxis andYAxis:(SChartAxis *)yAxis withWidth:(CGFloat)width withColor:(UIColor *)color

Declared In

SChartAnnotation.h

Instance Methods

updateViewWithCanvas:

Updates the annotation on the chart.

- (void)updateViewWithCanvas:(SChartCanvas *)canvas

Discussion

Override this method to provide custom updating of the annotation while it is being positioned on the chart.

Declared In

SChartAnnotation.h