Methods



addDataPoint:toLineIndex:

- (void)addDataPoint:(NSPoint)inPoint toLineIndex:(unsigned int)inLineIndex; 

Adds a point to the end of a specific line's data. The data must have either been nil previously, returned as a NSMutableArray by the dataSources -twoDGraphView:dataForLineIndex: method, or returned as a NSMutableData by the dataSources -twoDGraphView:dataObjectForLineIndex: method. The graph is scheduled for redrawing if the liveRefresh flag is set for the view. This can be used for incremental graphing, such as when each point requires significant calculation.

See also, the -liveRefresh and -setLiveRefresh: methods for additional information.

Parameters

NameDescription
inPointA point to add to the end of the line's data.
inLineIndexThe zero based index of the line to add to.

axisInsetForAxis:

- (float)axisInsetForAxis:(SM2DGraphAxisEnum)inAxis; 

Returns the pixel inset from the edge of the graph paper area to start the axis range. The default is zero.

Parameters

NameDescription
inAxisThe axis to return.
Result: The number of pixels to inset the line range.

backgroundColor

- (NSColor *)backgroundColor; 

Returns the color used to draw the background of the receiver. The default background color is white.

Result: The color used to draw the background.

barWidth

+ (float)barWidth; 

Returns the pixel width of a bar for bar graphs. Useful for calculating graph insets if multiple line bar graphs are going to be displayed.

Result: The width (in pixels) of a bar for bar graphs.

borderColor

- (NSColor *)borderColor; 

Returns the color used to draw the border of the graph area. The default color is black.

Result: The color used to draw the border of the graph area.

convertPoint:fromView:toLineIndex:

- (NSPoint)convertPoint:(NSPoint)inPoint fromView:(NSView *)inView toLineIndex:(unsigned int)inLineIndex; 

Converts a point from a given window/view coordinate system to a point in the coordinate system of a given line on the graph. For example, if the x range values for a line are from -10.0 to +10.0 the returned point will be in this range.

This is very useful when calling it from the -twoDGraphView:didClickPoint: delegate method.

Parameters

NameDescription
inPointThe point to be converted.
inViewThe inPoint parameter is in this view's coordinate system. A value of nil means the window's coordinate system.
inLineIndexZero based index of a line displayed on the graph.
Result: The point after conversion to the appropriate line's scale.

dataSource

- (id)dataSource; 

Returns the object that line data is pulled from.

Result: The data source object of the graph view.

delegate

- (id)delegate; 

Returns the delegate object for the graph view.

Result: The delegate object.

drawsGrid

- (BOOL)drawsGrid; 

Returns YES if the receiver draws grid lines on the graph, NO if it doesn't. The default is NO.

Result: YES if the receiver draws grid lines, NO if it doesn't.

drawsLineAtZeroForAxis:

- (BOOL)drawsLineAtZeroForAxis:(SM2DGraphAxisEnum)inAxis; 

Can draw a straight line at zero for the first line. This is useful if your range goes both above and below zero, and zero does not land on a standard grid line. The default is NO.

Parameters

NameDescription
inAxisThe axis to return.
Result: YES if drawing a straight line at zero for the first line.

gridColor

- (NSColor *)gridColor; 

Returns the color used to draw grid lines. The default color is blue.

Result: The color used to draw grid lines.

imageOfView

- (NSImage *)imageOfView; 

Returns an autoreleased image of the entire graph view. This image is filled with a white background first, so it should not have any transparent parts.

Result: An NSImage object of the entire graph view.

labelForAxis:

- (NSString *)labelForAxis:(SM2DGraphAxisEnum)inAxis; 

Returns the axis label for an axis. The default is no label (nil).

Parameters

NameDescription
inAxisThe axis to return.
Result: An autoreleased string or nil.

liveRefresh

- (BOOL)liveRefresh; 

Returns the state of the liveRefresh flag. This flag is only used in the -addDataPoint:toLineIndex: method to determine if the graph should be automatically redrawn or not. The default value is NO.

Result: The state of the liveRefresh flag.

numberOfMinorTickMarksForAxis:

- (int)numberOfMinorTickMarksForAxis:(SM2DGraphAxisEnum)inAxis; 

Returns the number of minor tick marks between each major tick mark for an axis. The default is no minor tick marks.

Parameters

NameDescription
inAxisThe axis to count.
Result: The number of minor tick marks for an axis.

numberOfTickMarksForAxis:

- (int)numberOfTickMarksForAxis:(SM2DGraphAxisEnum)inAxis; 

Returns the number of major tick marks for an axis. The default is no tick marks.

Parameters

NameDescription
inAxisThe axis to count.
Result: The number of major tick marks for an axis.

refreshDisplay:

- (IBAction)refreshDisplay:(id)sender; 

Simple cover method that calls -reloadData, then -reloadAttributes.

Parameters

NameDescription
senderAny object or nil; unused.

reloadAttributes

- (void)reloadAttributes; 

Reloads all line attributes from the datasource and schedules the graph for redrawing. The line data points are not reloaded.


reloadAttributesForLineIndex:

- (void)reloadAttributesForLineIndex:(unsigned int)inLineIndex; 

Reloads a specific line's attributes from the datasource and schedules the graph for redrawing. The line data points are not reloaded.

Parameters

NameDescription
inLineIndexThe zero based index of the line to reload.

reloadData

- (void)reloadData; 

Reloads all line data from the datasource and schedules the graph for redrawing.


reloadDataForLineIndex:

- (void)reloadDataForLineIndex:(unsigned int)inLineIndex; 

Reloads a specific line's data from the datasource and schedules the graph for redrawing.

Parameters

NameDescription
inLineIndexThe zero based index of the line to reload.

setAxisInset:forAxis:

- (void)setAxisInset:(float)inInset forAxis:(SM2DGraphAxisEnum)inAxis; 

Sets the pixel inset from the edge of the graph paper area to start the axis range. The default is zero.

Parameters

NameDescription
inInsetThe number of pixels to inset the line range.
inAxisThe axis to change.

setBackgroundColor:

- (void)setBackgroundColor:(NSColor *)inColor; 

Sets the receiver's background color to aColor. The default is white. If set to nil, no background is drawn.

See Also: -setDrawsGrid:, -drawsGrid, -setGridColor:, -gridColor, and -backgroundColor.

Parameters

NameDescription
inColorThe new background color.

setBorderColor:

- (void)setBorderColor:(NSColor *)inColor; 

Sets the color used to draw the border of the graph area. The default color is black.

See Also: -setDrawsGrid:, -drawsGrid, -gridColor, -setBackgroundColor:, and -backgroundColor.

Parameters

NameDescription
inColorThe color to draw grid lines.

setDataSource:

- (void)setDataSource:(id)inDataSource; 

Set the object that line data is pulled from. This works in exactly the same way that NSTableView and NSOutlineView have data source objects.

The data source is checked to see if responds to methods in the SM2DGraphDataSource category.

Parameters

NameDescription
inDataSourceThe new data source.

setDelegate:

- (void)setDelegate:(id)inDelegate; 

Set the delegate object for the graph view.

The delegate is checked to see if responds to any of the methods in the SM2DGraphDelegate category.

Parameters

NameDescription
inDelegateThe new delegate object.

setDrawsGrid:

- (void)setDrawsGrid:(BOOL)inFlag; 

Controls whether the receiver draws grid lines on the graph. The default is NO.

See Also: -drawsGrid, -setGridColor:, -gridColor, -setBackgroundColor: and -backgroundColor.

Parameters

NameDescription
inFlagIf YES the receiver draws grid lines; if NO it doesn't.

setDrawsLineAtZero:forAxis:

- (void)setDrawsLineAtZero:(BOOL)inNewValue forAxis:(SM2DGraphAxisEnum)inAxis; 

Can draw a straight line at zero for the first line. This is useful if your range goes both above and below zero, and zero does not land on a standard grid line. The default is NO.

Parameters

NameDescription
inNewValueSet to YES if you want to draw a straight line at zero for the first line.
inAxisThe axis to change.

setGridColor:

- (void)setGridColor:(NSColor *)inColor; 

Sets the color used to draw grid lines. The default color is blue.

See Also: -setDrawsGrid:, -drawsGrid, -gridColor, -setBackgroundColor:, and -backgroundColor.

Parameters

NameDescription
inColorThe color to draw grid lines.

setLabel:forAxis:

- (void)setLabel:(NSString *)inNewLabel forAxis:(SM2DGraphAxisEnum)inAxis; 

Sets the axis label for an axis. The default is no label (nil).

Parameters

NameDescription
inNewLabelThe new label. If nil, any existing label is removed.
inAxisThe axis to label.

setLiveRefresh:

- (void)setLiveRefresh:(BOOL)inFlag; 

Sets the state of the liveRefresh flag. This flag is only used in the -addDataPoint:toLineIndex: method to determine if the graph should be automatically redrawn or not. The default value is NO.

Parameters

NameDescription
inFlagThe desired state of the liveRefresh flag.

setNumberOfMinorTickMarks:forAxis:

- (void)setNumberOfMinorTickMarks:(int)count forAxis:(SM2DGraphAxisEnum)inAxis; 

Sets the number of minor tick marks between each major tick mark for an axis. The default is no minor tick marks.

Parameters

NameDescription
countThe number of minor tick marks between major tick marks.
inAxisThe axis to change.

setNumberOfTickMarks:forAxis:

- (void)setNumberOfTickMarks:(int)count forAxis:(SM2DGraphAxisEnum)inAxis; 

Sets the number of major tick marks for an axis. The default is no tick marks.

Parameters

NameDescription
countThe number of major tick marks. Should not be one.
inAxisThe axis to change.

setTag:

- (void)setTag:(int)inTag; 

Sets the tag of the receiver to inTag. This is an integer you can use for whatever you'd like.

Parameters

NameDescription
inTagThe new tag of the receiver.

setTickMarkPosition:forAxis:

- (void)setTickMarkPosition:(NSTickMarkPosition)position forAxis:(SM2DGraphAxisEnum)inAxis; 

Sets the position to draw tick marks for an axis. The default is NSTickMarkBelow and NSTickMarkRight. Note: Currently, this setting is remembered but does nothing.

Parameters

NameDescription
positionThe position to draw tick marks.
inAxisThe axis to change.

tag

- (int)tag; 

Returns the tag of the receiver. This is an integer you can use for whatever you'd like.

Result: The tag of the receiver.

tickMarkPositionForAxis:

- (NSTickMarkPosition)tickMarkPositionForAxis:(SM2DGraphAxisEnum)inAxis; 

Returns the position to draw tick marks for an axis. The default is NSTickMarkBelow and NSTickMarkRight. Note: Currently, this setting is remembered but does nothing.

Parameters

NameDescription
inAxisThe axis to return.
Result: The position to draw tick marks for an axis.

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