NSObject(SMPieChartDataSource)



Discussion

An object should implement most of the methods in this category to return data to be displayed on a pie chart. These methods are optional: -pieChartView:attributesForSliceIndex:, -numberOfExplodedPartsInPieChartView:, and -pieChartView:rangeOfExplodedPartIndex:.

Methods

numberOfExplodedPartsInPieChartView:

- (unsigned int)numberOfExplodedPartsInPieChartView:(SMPieChartView *)inPieChartView; 

This method is optional. However, if this is implemented -pieChartView:rangeOfExplodedPartIndex: must also be implemented.

Asks the datasource to report the number of groups of exploded slices in a particular pie view. Exploded slices are moved out from the center of the chart by the explodeDistance.

Parameters

NameDescription
inPieChartViewThe pie view making the call.
Result: Should return the number of exploded groups of slices.

numberOfSlicesInPieChartView:

- (unsigned int)numberOfSlicesInPieChartView:(SMPieChartView *)inPieChartView; 

Asks the datasource to report the number of slices to be drawn in a particular pie view.

Parameters

NameDescription
inPieChartViewThe pie view making the call.
Result: Should return the number of slices to draw.

pieChartView:attributesForSliceIndex:

- (NSDictionary *)pieChartView:(SMPieChartView *)inPieChartView attributesForSliceIndex:(unsigned int)inSliceIndex; 

Implementing this method is optional. Asks the datasource for the drawing attributes to use when drawing a particular slice. If the datasource does not respond to this message, or returns nil, default values are used. See the constants section of the documentation for keys that can be used.

Parameters

NameDescription
inPieChartViewThe pie view making the call.
inSliceIndexThe zero based slice index to return.
Result: A dictionary of attributes to use to draw the slice; can return nil if default values are wanted.

pieChartView:dataForSliceIndex:

- (double)pieChartView:(SMPieChartView *)inPieChartView dataForSliceIndex:(unsigned int)inSliceIndex; 

Either this method or -pieChartViewArrayOfSliceData: must be implemented.

Asks the datasource to report the actual data for a particular slice. The data should be returned as a double. Any scale can be used, but all slices should use the same scale.

Parameters

NameDescription
inPieChartViewThe pie view making the call.
inSliceIndexThe zero based slice index to return.
Result: A double.

pieChartView:rangeOfExplodedPartIndex:

- (NSRange)pieChartView:(SMPieChartView *)inPieChartView rangeOfExplodedPartIndex:(unsigned int)inIndex; 

This method is optional. However, if this is implemented -numberOfExplodedPartsInPieChartView: must also be implemented.

Asks the datasource to report the range of slices of an exploded group. Exploded slices are moved out from the center of the chart by the explodeDistance. For example, if the first two slices should be exploded, this should return a range with location equal to 0 and length equal to two.

Parameters

NameDescription
inPieChartViewThe pie view making the call.
inIndexThe zero based slice index to return.
Result: A range of an exploded group of slices.

pieChartViewArrayOfSliceData:

- (NSArray *)pieChartViewArrayOfSliceData:(SMPieChartView *)inPieChartView; 

Either this method or -pieChartView:dataForSliceIndex: must be implemented.

This method asks the datasource to report all slice data in an NSArray. The slice data should be an array of objects that respond to -doubleValue (like NSNumber).

Parameters

NameDescription
inPieChartViewThe pie view making the call.
Result: An NSArray of objects. Should not be nil.

© 2003-2004 Snowmint Creative Solutions LLC (Last Updated 8/29/2004)