ORKGraphChartViewDataSource Protocol Reference

Conforms to NSObject
Declared in ORKGraphChartView.h

The abstract ORKGraphChartViewDataSource protocol is the base protocol which conforms the basis for the ORKValueRangeGraphChartViewDataSource and ORKValueStackGraphChartViewDataSource protocols, required to populate the concrete ORKGraphChartView subclass.

At a minimum, a data source object must implement the graphChartView:numberOfPointsInPlot: and graphChartView:plot:valueForPointAtIndex: methods. These methods return the number of points in a plot and the points themselves. Each point in a plot is represented by an object of the ORKValueRange or ORKValueStack class, depending on the concrete subprotocol.

A data source object may provide additional information to the graph chart view by implementing the optional methods.

When configuring an ORKGraphChartView object, assign your data source to its dataSource property.

– graphChartView:numberOfDataPointsForPlotIndex: required method

Asks the data source for the number of value points to be plotted by the graph chart view at the specified plot index.

- (NSInteger)graphChartView:(ORKGraphChartView *)graphChartView numberOfDataPointsForPlotIndex:(NSInteger)plotIndex

Parameters

graphChartView

The graph chart view asking for the number of value points.

plotIndex

An index number identifying the plot in the graph chart view. This index is 0 in a single-plot graph chart view.

Return Value

The number of range points in the plot at plotIndex.

Declared In

ORKGraphChartView.h

– numberOfPlotsInGraphChartView: required method

Asks the data source for the number of plots to be plotted by the graph chart view.

- (NSInteger)numberOfPlotsInGraphChartView:(ORKGraphChartView *)graphChartView

Parameters

graphChartView

The graph chart view asking for the number of plots.

Return Value

The number of plots in the graph chart view.

Declared In

ORKGraphChartView.h

– graphChartView:colorForPlotIndex:

Asks the data source for the color of the specified plot.

- (UIColor *)graphChartView:(ORKGraphChartView *)graphChartView colorForPlotIndex:(NSInteger)plotIndex

Parameters

graphChartView

The graph chart view asking for the color of the segment.

plotIndex

An index number identifying the plot in the graph chart view. This index is always 0 in single-plot graph chart views.

Return Value

The color of the segment at the specified index in a pie chart view.

Discussion

If this method is not implemented, the first plot uses the graph chart view tintColor, and all subsequent plots uses the current referenceLineColor.

Declared In

ORKGraphChartView.h

– graphChartView:fillColorForPlotIndex:

Asks the data source for the fill color of the specified plot.

- (UIColor *)graphChartView:(ORKGraphChartView *)graphChartView fillColorForPlotIndex:(NSInteger)plotIndex

Parameters

graphChartView

The graph chart view asking for the color of the segment.

plotIndex

An index number identifying the plot in the graph chart view. This index is always 0 in single-plot graph chart views.

Return Value

The color of the fill layer at the specified index in a line chart view.

Discussion

The fill color is only used by ORKLineGraphChartView. If this method is not implemented, the chart uses the main color of the specified plot with a 0.4 opacity value.

Declared In

ORKGraphChartView.h

– scrubbingPlotIndexForGraphChartView:

Asks the data source which plot the scrubber should snap to in multigraph chart views.

- (NSInteger)scrubbingPlotIndexForGraphChartView:(ORKGraphChartView *)graphChartView

Parameters

graphChartView

The graph chart view asking for the scrubbing plot index.

Return Value

The index of the plot that the scrubber should snap to.

Discussion

If this method is not implemented, the scrubber snaps over the first plot.

Declared In

ORKGraphChartView.h

– maximumValueForGraphChartView:

Asks the data source for the upper limit of the y-axis drawn by the graph chart view.

- (double)maximumValueForGraphChartView:(ORKGraphChartView *)graphChartView

Parameters

graphChartView

The graph chart view asking for the maximum value.

Return Value

The maximum value of the y-axis drawn by graphChartView.

Discussion

If this method is not implemented, the greatest maximumValue of all ORKValueRange instances returned in graphChartView:plot:valueForPointAtIndex: is used.

See also: graphChartView:plot:valueForPointAtIndex:.

Declared In

ORKGraphChartView.h

– minimumValueForGraphChartView:

Asks the data source for the lower limit of the y-axis drawn by the graph chart view.

- (double)minimumValueForGraphChartView:(ORKGraphChartView *)graphChartView

Parameters

graphChartView

The graph chart view asking for the minimum value.

Return Value

The minimum value of the y-axis drawn by graphChartView.

Discussion

If this method is not implemented, the smallest minimumValue of all ORKValueRange instances returned in graphChartView:plot:valueForPointAtIndex: is used.

See also: graphChartView:plot:valueForPointAtIndex:.

Declared In

ORKGraphChartView.h

– numberOfDivisionsInXAxisForGraphChartView:

Asks the data source for the number of divisions in the x-axis. The value is ignored if it is lower than the number of data points. A title appearing adjacent to each division may optionally be returned by the graphChartView:titleForXAxisAtPointIndex: method.

- (NSInteger)numberOfDivisionsInXAxisForGraphChartView:(ORKGraphChartView *)graphChartView

Parameters

graphChartView

The graph chart view asking for the number of divisions in its x-axis.

Return Value

The number of divisions in the x-axis for graphChartView.

Declared In

ORKGraphChartView.h

– graphChartView:titleForXAxisAtPointIndex:

Asks the data source for the title to be displayed adjacent to each division in the x-axis (the number returned by numberOfDivisionsInXAxisForGraphChartView:). You can return nil from this method if you don’t want to display a title for the specified point index.

- (nullable NSString *)graphChartView:(ORKGraphChartView *)graphChartView titleForXAxisAtPointIndex:(NSInteger)pointIndex

Parameters

graphChartView

The graph chart view asking for the title.

pointIndex

The index of the specified x-axis division.

Return Value

The title string to be displayed adjacent to each division of the x-axis of the graph chart view.

Discussion

If this method is not implemented, the x-axis has no titles.

See also: numberOfDivisionsInXAxisForGraphChartView:.

Declared In

ORKGraphChartView.h

– graphChartView:drawsVerticalReferenceLineAtPointIndex:

Asks the data source if the vertical reference line at the specified point index should be drawn..

- (BOOL)graphChartView:(ORKGraphChartView *)graphChartView drawsVerticalReferenceLineAtPointIndex:(NSInteger)pointIndex

Parameters

graphChartView

The graph view asking for the tile.

pointIndex

The index corresponding to the number returned by numberOfDivisionsInXAxisForGraphChartView:.

Return Value

Whether the graph chart view should draw the vertical reference line.

Discussion

If this method is not implemented, the graph chart view will draw all vertical reference lines.

Declared In

ORKGraphChartView.h

– graphChartView:drawsPointIndicatorsForPlotIndex:

Asks the data source if the plot at specified index should display circular indicators on its data points.

- (BOOL)graphChartView:(ORKGraphChartView *)graphChartView drawsPointIndicatorsForPlotIndex:(NSInteger)plotIndex

Parameters

graphChartView

The graph view asking whether point indicators should be drawn.

plotIndex

An index number identifying the plot in the graph chart view. This index is always 0 in single-plot graph chart views.

Return Value

Whether the graph chart view should draw point indicators for its points.

Discussion

This only applys to ORKLineGrapthChartView. If this method is not implemented, point indicators will be drawn for all plots.

Declared In

ORKGraphChartView.h

– graphChartView:accessibilityUnitLabelForPlotIndex:

Asks the data source for the unit label for the given plot index so VoiceOver’s description of the graph can be read with units.

- (NSString *)graphChartView:(ORKGraphChartView *)graphChartView accessibilityUnitLabelForPlotIndex:(NSInteger)plotIndex

Parameters

graphChartView

The graph view asking for its unit label

plotIndex

An index number identifying the plot in the graph chart view. This index is always 0 in single-plot graph chart views.

Return Value

An appropriate unit label for the given plot.

Discussion

If this method is not implemented, VoiceOver will speak the graph value without units.

Declared In

ORKGraphChartView.h

– graphChartView:accessibilityLabelForXAxisAtPointIndex:

Asks the data source for the accessibilityLabel at a given point on the x-axis

- (NSString *)graphChartView:(ORKGraphChartView *)graphChartView accessibilityLabelForXAxisAtPointIndex:(NSInteger)pointIndex

Parameters

graphChartView

The graph view asking for its unit label

pointIndex

The index corresponding to the number returned by numberOfDivisionsInXAxisForGraphChartView:.

Return Value

An appropriate accessibility label for the given index of the graph.

Discussion

This is used in cases where the UI may be displaying a shortened form (e.g. M, T, W, etc. for days of the week), but VoiceOver should be speaking the longer form. If this method isn’t implemented, VoiceOver will speak the label displayed in the UI for the given index.

Declared In

ORKGraphChartView.h