Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Axis Labels

Boris-Em edited this page Jun 10, 2014 · 19 revisions

BEMSimpleLineGraph offers an easy way to include labels along the graph's axis.

##X-Axis To add labels along the X-Axis, simply implement the two followings methods: numberOfGapsBetweenLabelsOnLineGraph: and lineGraph:labelOnXAxisForIndex:.

Gaps between labels
Informs how much empty space is needed between each displayed label. Returning 0 will display all of the labels. Returning the total number of labels will only display the first and last label. See the image below for clarification.

- (NSInteger)numberOfGapsBetweenLabelsOnLineGraph:(BEMSimpleLineGraphView *)graph {
	return X; // The number of hidden labels between each displayed label.
}

On the left, numberOfGapsBetweenLabelsOnLineGraph: returns 0, in the middle it returns 1 and on the right it returns the number of points in the graph.

Label on X Axis
The text to be displayed for each UILabel on the X-Axis at a given index. It should return as many strings as the number of points on the graph.

- (NSString *)lineGraph:(BEMSimpleLineGraphView *)graph labelOnXAxisForIndex:(NSInteger)index {
	return …;
}

X-Axis Label Color
The property colorXaxisLabel controls the color of the text of the UILabels on the X-Axis:

@property (strong, nonatomic) UIColor *colorXaxisLabel;

##Y-Axis The master branch of the project doesn't support labels on the Y-axis for now. It is expected to be supported with the release of the v3.0. However, this feature is supported on the feature branch. Please make sure to read the feature branch warning before working with it.