ORKPieChartViewDataSource Protocol Reference

Conforms to NSObject
Declared in ORKPieChartView.h

An object that adopts the ORKPieChartViewDataSource protocol is responsible for providing the data required to populate an ORKPieChartView object.

At a minimumm, a data source object must implement the numberOfSegmentsInPieChartView and pieChartView:valueForSegmentAtIndex: methods. These methods are responsible for returning the number of segments in a pie chart view and the value for each segment. A data source object may provide additional information to the pie chart by implementing the optional ORKPieChartViewDataSource methods.

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

– numberOfSegmentsInPieChartView: required method

Asks the data source for the number of segments in the pie chart view.

- (NSInteger)numberOfSegmentsInPieChartView:(ORKPieChartView *)pieChartView

Parameters

pieChartView

The pie chart view asking for the number of segments.

Return Value

The number of segments in the pie chart view.

Declared In

ORKPieChartView.h

– pieChartView:valueForSegmentAtIndex: required method

Asks the data source for the value of a segment in the pie chart view.

- (CGFloat)pieChartView:(ORKPieChartView *)pieChartView valueForSegmentAtIndex:(NSInteger)index

Parameters

pieChartView

The pie chart view asking for the value of the segment.

index

An index number specifying the segment in the pie chart view.

Return Value

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

Discussion

The value can be any arbitrary integer: the pie chart view normalizes them by the sum of all returned values.

Declared In

ORKPieChartView.h

– pieChartView:colorForSegmentAtIndex:

Asks the data source for the color of a segment in the pie chart view.

- (UIColor *)pieChartView:(ORKPieChartView *)pieChartView colorForSegmentAtIndex:(NSInteger)index

Parameters

pieChartView

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

index

An index number specifying the segment in the pie chart view.

Return Value

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

Discussion

If this method is not implemented, the pie chart view uses a unique shade of the current tint color for each segment.

Declared In

ORKPieChartView.h

– pieChartView:titleForSegmentAtIndex:

Asks the data source for the title to appear in the legend for a segment in the pie chart view.

- (NSString *)pieChartView:(ORKPieChartView *)pieChartView titleForSegmentAtIndex:(NSInteger)index

Parameters

pieChartView

The pie chart view asking for the title.

index

An index number specifying the segment in the pie chart view.

Return Value

The title of the segment at the specified index in the pie chat view’s legend.

Discussion

If this method is not implemented, the pie chart view does not display the legend.

Declared In

ORKPieChartView.h