-
Notifications
You must be signed in to change notification settings - Fork 381
Average Lines
Graphs with BEMSimpleLineGraph are drawn with a single line and have an optional average line available for drawing.
The average line can be set to any y-value and drawn in a straight, horizontal line across the graph.
The averageLine
property is a BEMAverageLine which allows you to enable and customize the average line. Set its enableAverageLine
property to YES to display the line.
self.myGraph.averageLine.enableAverageLine = YES;
You do not need to initialize the averageLine
object. BEMSimpleLineGraph will initialize it for you.
You may optionally set a y-value for your average line. If you do not set a y-value, the average (mean) of your points will be calculated (using the calculateAveragePointValue
method) and used. Otherwise, you may specify your own y-value which could be any number on the graph (e.g. sum, median, mode, max, min, etc.).
Set the y-value of the average line by passing a float relative to the scale of your graph. For example, if your graph's y-values range between 25 and 100 pass a y-value within that range. BEMSimpleLineGraph will not validate your y-value, so it is imperative that you ensure it will be within viewing range.
self.myGraph.averageLine.yValue = [self.myGraph calculateAveragePointValue].floatValue;
There are four additional properties that can be set on the average line. These properties provide similar functionality to the properties of reference lines and the main line.
color
Specify the color of the average line. Defaults to white.
width
Specify the width of the average line. Defaults to 3.0f.
alpha
Specify the opacity of the average line. Defaults to 1.0f.
dashPattern
Specify an NSArray dash pattern for the average line. Defaults to nil.