NSObject(SM2DGraphDataSource)



Discussion

An object should implement most of the methods in this category to return data to be displayed on a graph view. Only -twoDGraphView:attributesForLineIndex: is optional.

Methods

numberOfLinesInTwoDGraphView:

- (unsigned int)numberOfLinesInTwoDGraphView:(SM2DGraphView *)inGraphView; 

Asks the datasource to report the number of data lines to be drawn in a particular graph view.

Parameters

NameDescription
inGraphViewThe graph view making the call.
Result: Should return the number of data lines to graph.

twoDGraphView:attributesForLineIndex:

- (NSDictionary *)twoDGraphView:(SM2DGraphView *)inGraphView attributesForLineIndex:(unsigned int)inLineIndex; 

Implementing this method is optional. Asks the datasource for the drawing attributes to use when drawing a particular line. 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
inGraphViewThe graph view making the call.
inLineIndexThe zero based data line index to return.
Result: A dictionary of attributes to use to draw the line; can return nil if default values are wanted.

twoDGraphView:dataForLineIndex:

- (NSArray *)twoDGraphView:(SM2DGraphView *)inGraphView dataForLineIndex:(unsigned int)inLineIndex; 

Either this method or -twoDGraphView:dataObjectForLineIndex: must be implemented. You can implement one or the other, or both if you want a mix of data types.

Asks the datasource to report the actual data points for a particular line. The points should be returned as an NSArray of NSPoints as strings; you can use the function NSStringFromPoint to do the conversion.

Parameters

NameDescription
inGraphViewThe graph view making the call.
inLineIndexThe zero based data line index to return.
Result: An NSArray (or NSMutableArray) of NSPoints as strings. Can be nil if no points are on this line.

twoDGraphView:dataObjectForLineIndex:

- (NSData *)twoDGraphView:(SM2DGraphView *)inGraphView dataObjectForLineIndex:(unsigned int)inLineIndex; 

Either this method or -twoDGraphView:dataForLineIndex: must be implemented. You can implement one or the other, or both if you want a mix of data types.

This method asks the datasource to report the actual data points for a particular line. The points should be returned as an NSData containing an array of NSPoints (or CGPoints since they're the same thing). The length of the NSData object should be an exact multiple of sizeof(NSPoint).

Parameters

NameDescription
inGraphViewThe graph view making the call.
inLineIndexThe zero based data line index to return.
Result: An NSData (or NSMutableData) of NSPoints (or CGPoints). Can be nil if no points are on this line.

twoDGraphView:maximumValueForLineIndex:forAxis:

- (double)twoDGraphView:(SM2DGraphView *)inGraphView maximumValueForLineIndex:(unsigned int)inLineIndex
            forAxis:(SM2DGraphAxisEnum)inAxis; 

Asks the datasource to report the maximum axis value to use for a particular line. For example, if your line data points y value ranges from 1 to 9, you may want to graph from 0 to 10; in that case, you would return 10 as a maximum.

This sets the scale to be used to display the line.

Parameters

NameDescription
inGraphViewThe graph view making the call.
inLineIndexThe zero based data line index to return.
inAxisThe axis requested.
Result: A number to use for the maximum value of the scale.

twoDGraphView:minimumValueForLineIndex:forAxis:

- (double)twoDGraphView:(SM2DGraphView *)inGraphView minimumValueForLineIndex:(unsigned int)inLineIndex
            forAxis:(SM2DGraphAxisEnum)inAxis; 

Asks the datasource to report the minimum axis value to use for a particular line. For example, if your line data points y value ranges from 1 to 9, you may want to graph from 0 to 10; in that case, you would return 0 as a minimum.

This sets the scale to be used to display the line.

Parameters

NameDescription
inGraphViewThe graph view making the call.
inLineIndexThe zero based data line index to return.
inAxisThe axis requested.
Result: A number to use for the minimum value of the scale.

© 2003 Snowmint Creative Solutions LLC (Last Updated 9/4/2003)