SMPieChartView



Discussion

NSView subclass that conforms to the NSCoding protocol.

Displays a pie chart. The pie view works in a very similar fashion to NSTableView, NSOutlineView, and NSBrowser.

A datasource object provides all of the slice data and attributes to display the pie chart. A delegate object can respond to some methods for more control over the display and behavior of the pie view.

Methods

attributedTitle

- (NSAttributedString *)attributedTitle; 

Returns the attributed title of the pie chart. The default is no title (nil).

Result: An autoreleased string or nil.

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.

borderColor

- (NSColor *)borderColor; 

Returns the color used to draw the border of each slice. The default color is black.

Result: The color used to draw the border of each slice.

convertToSliceFromPoint:fromView:

- (int)convertToSliceFromPoint:(NSPoint)inPoint fromView:(NSView *)inView; 

Converts a point from a given window/view coordinate system to a slice of the pie, or -1 if the click was not on a slice of the pie. For example, if there are two slices of the pie (left half and right half) and the user clicks on the left half, this would return 0.

This is very useful when called from the -pieChartView: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.
Result: The slice of the pie that was clicked on. If the point is not on a slice of pie, returns -1.

dataSource

- (id)dataSource; 

Returns the object that slice data is pulled from.

Result: The data source object of the pie view.

delegate

- (id)delegate; 

Returns the delegate object for the pie view.

Result: The delegate object.

explodeDistance

- (float)explodeDistance; 

Returns the pixel offset from the center of the chart to draw exploded slices of the pie. The default is zero.

Result: The number of pixels to offset exploded parts of the pie.

imageOfView

- (NSImage *)imageOfView; 

Returns an autoreleased image of the entire chart 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 chart view.

labelPosition

- (SMLabelPositionEnum)labelPosition; 

Returns the position of labels for the pie chart. The default is no labels.

Result: The position of labels.

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 slice attributes from the datasource and schedules the chart for redrawing. The slice data is not reloaded.


reloadAttributesForSliceIndex:

- (void)reloadAttributesForSliceIndex:(unsigned int)inSliceIndex; 

Reloads a specific slice's attributes from the datasource and schedules the chart for redrawing. The slice data is not reloaded.

Parameters

NameDescription
inSliceIndexThe zero based index of the slice to reload.

reloadData

- (void)reloadData; 

Reloads all slice data from the datasource and schedules the chart for redrawing.


setAttributedTitle:

- (void)setAttributedTitle:(NSAttributedString *)inNewTitle; 

Sets the attributed title of the pie chart. The default is no title (nil).

Parameters

NameDescription
inNewTitleThe new title. If nil, any existing title is removed.

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 each slice. The default color is black.

See Also: -setBackgroundColor:, and -backgroundColor.

Parameters

NameDescription
inColorThe color to draw the border of each slice.

setDataSource:

- (void)setDataSource:(id)inDataSource; 

Set the object that slice 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 SMPieChartDataSource category.

Parameters

NameDescription
inDataSourceThe new data source.

setDelegate:

- (void)setDelegate:(id)inDelegate; 

Set the delegate object for the pie view.

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

Parameters

NameDescription
inDelegateThe new delegate object.

setExplodeDistance:

- (void)setExplodeDistance:(float)inDistance; 

Sets the pixel offset from the center of the chart to draw exploded slices of the pie. The default is zero.

Parameters

NameDescription
inDistanceThe number of pixels to offset exploded parts of the pie.

setLabelPosition:

- (void)setLabelPosition:(SMLabelPositionEnum)inNewValue; 

Sets the position of labels for the pie chart. The default is no labels.

Parameters

NameDescription
inNewValueThe new label position value.

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.

setTitle:

- (void)setTitle:(NSString *)inNewTitle; 

Sets the title of the pie chart. The default is no title (nil).

Parameters

NameDescription
inNewTitleThe new title. If nil, any existing title is removed.

setTitlePosition:

- (void)setTitlePosition:(SMTitlePosition)inPosition; 

Sets the position of the title. The default is SMTitlePositionBelow.

Parameters

NameDescription
inPositionThe position to draw the title in.

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.

title

- (NSString *)title; 

Returns the title of the pie chart. The default is no title (nil).

Result: An autoreleased string or nil.

titlePosition

- (SMTitlePosition)titlePosition; 

Returns the position of the title. The default is SMTitlePositionBelow.

Result: The number of position to draw the title in.

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