SChartDonutSeries Class Reference

Inherits from SChartRadialSeries : SChartSeries : NSObject
Declared in SChartDonutSeries.h
Availability Standard
Premium
Related samples PieChart

Overview

SChartDonutSeries displays magnitude data on the chart - the larger the value of the data point, the larger the slice representing that data point.

A donut series contains an instance of SChartDonutSeriesStyle, which manages its appearance.

You can configure the radius of the slices in the chart, and how big the hole in the middle of the donut is. See innerRadius and outerRadius for more information.

When a slice is selected in the chart, it protrudes out of the donut, and rotates to a given position. You can set the amount of protrusion which a selected slice has by setting the [SChartDonutSeriesStyle protrusion] property on the series selectedStyle. You can set the position it rotates to using the selectedPosition property. The series contains an instance of SChartAnimation which describes the motion of the slice as it rotates to its selected position. See selectionAnimation for more information.

You can enable panning on a donut series. If panning is enabled, performing a swipe gesture on the series will cause it to rotate. Whether panning is enabled is controlled by the gesturePanningEnabled property. By default this is set to NO.

Legends on donut charts show an entry for each data point, or slice, of the donut series.

Properties

drawDirection

The direction in which data is drawn around the centre of the plot.

@property (nonatomic) SChartRadialSeriesDrawDirection drawDirection

Discussion

  • SChartRadialSeriesDrawDirectionClockwise: Configures the direction in which the data is drawn around the center of the plot to be clockwise.
  • SChartRadialSeriesDrawDirectionAntiClockwise: Configures the direction in which the data is drawn around the center of the plot to be anticlockwise.

This defaults to SChartRadialSeriesDrawDirectionAntiClockwise.

Declared In

SChartDonutSeries.h

gesturePanningEnabled

Defines whether or not panning is enabled on this series.

@property (nonatomic) BOOL gesturePanningEnabled

Discussion

If panning is enabled, performing a swipe gesture on the series will cause it to rotate. The series will stay under your finger whilst your finger remains on the series. Once you lift your finger, the series will begin to decelerate. The rotationFriction property controls the rate at which the series will decelerate.

The default value for this property is NO.

Declared In

SChartDonutSeries.h

innerRadius

The inner radius of the series, in points.

@property (nonatomic) CGFloat innerRadius

Declared In

SChartDonutSeries.h

labelFormatString

A format string to use for the labels which annotate data within a radial series.

@property (nonatomic, retain) NSString *labelFormatString

Discussion

A typical example of the labels would be the labels on each slice in a pie chart.

This defaults to @“%.2f”

Declared In

SChartDonutSeries.h

outerRadius

The outer radius of the series, in points.

@property (nonatomic) CGFloat outerRadius

Declared In

SChartDonutSeries.h

rotation

The current rotation of the series, in radians.

@property (nonatomic) CGFloat rotation

Declared In

SChartDonutSeries.h

rotationFriction

The amount of friction applied to this pie series after a rotation (pan) gesture finishes, and the series begins to decelerate.

@property (nonatomic) CGFloat rotationFriction

Discussion

The friction is defined as the percentage of decay of velocity per frame. The default value is 0.02, or 2%.

Declared In

SChartDonutSeries.h

selectedPosition

The angle to which the slice will rotate once selected, in radians.

@property (nonatomic, retain) NSNumber *selectedPosition

Declared In

SChartDonutSeries.h

selectionAnimation

An animation object describing the motion of the donut series when a slice is selected.

@property (nonatomic, retain) SChartAnimation *selectionAnimation

Discussion

The angleCurve of the animation describes any rotation of the series from its current position to its selected position. The radiusCurve describes the animation of any increase or decrease in the protrusion of the slice as a result of being selected or deselected.

See Also

Declared In

SChartDonutSeries.h

selectionAnimationDuration

The time taken for ‘selectionAnimation’ to complete, in seconds.

@property (nonatomic, assign) CGFloat selectionAnimationDuration

Discussion

Default is 1.

Declared In

SChartDonutSeries.h

selectionEnabledDuringPanning

By default, tapping on a radial series during panning will just stop the pan. If this property is enabled, tapping on a slice in the series will select that slice. This property defaults to NO.

@property (nonatomic, assign) BOOL selectionEnabledDuringPanning

Discussion

If this property is enabled, and selectedPosition is not set to a value, the donut series will keep spinning whilst a slice moves out. The same is true for the case where a slice moves in once it is deselected.

Declared In

SChartDonutSeries.h

Instance Methods

getDonutCenter

Returns the center of the donut, within the chart frame.

- (CGPoint)getDonutCenter

Declared In

SChartDonutSeries.h

getSliceCenter:

Returns the center of the slice at a given index, within the chart frame.

- (CGPoint)getSliceCenter:(NSInteger)sliceIndex

Parameters

sliceIndex

The index of the slice in which we are interested.

Declared In

SChartDonutSeries.h

indexOfSliceAtAngle:

Returns the index of the slice in the donut series which is at the given angle in radians.

- (NSInteger)indexOfSliceAtAngle:(double)rads

Parameters

rads

The angle in radians at which we wish to find the donut slice.

Declared In

SChartDonutSeries.h

rotateSliceAtIndex:toAngle:withAnimation:

Rotates the specified slice to the specified angle in radians, with the provided animation.

- (void)rotateSliceAtIndex:(NSInteger)index toAngle:(double)rads withAnimation:(SChartAnimation *)animation

Parameters

index

The index of the slice in the series to rotate.

rads

The angle to which to rotate the specified slice, in radians.

animation

The animation to use during the rotation.

Declared In

SChartDonutSeries.h

selectedStyle

Manages the appearance of the donut series when it is selected.

- (SChartDonutSeriesStyle *)selectedStyle

Discussion

Style settings in this object will be applied when the series is marked as selected (or a slice is selected).

The default settings of the style are inherited from the chart theme. You can tweak the appearance of the series by modifying the style.

Declared In

SChartDonutSeries.h

setSelectedStyle:

Sets the style object for the scatter series when it is selected.

- (void)setSelectedStyle:(SChartDonutSeriesStyle *)selectedStyle

Parameters

selectedStyle

The new style object to use.

See Also

Declared In

SChartDonutSeries.h

setSlice:asSelected:

Select or deselect a slice within the series.

- (void)setSlice:(NSInteger)sliceIndex asSelected:(BOOL)sel

Parameters

sliceIndex

The index of the slice in the series to select or deselect.

sel

YES if we are selecting the slice. NO otherwise.

Declared In

SChartDonutSeries.h

setSpokeStyle:forSpokeAtSliceIndex:

Set a spoke’s style for a specific slice.

- (void)setSpokeStyle:(SChartSpokeStyle *)spokeStyle forSpokeAtSliceIndex:(NSInteger)sliceIndex

Parameters

spokeStyle

The style defining the spoke’s attributes for the next draw cycle

sliceIndex

The slice index of the spoke the style should apply to

Discussion

This enables spokes to be styled individually on a slice-by-slice basis.

NOTE: SChartSpokeStyle conforms to NSCopying, therefore custom styles can use the series' default or selected spoke styles as a foundation for any alterations.

Any changes made to the spoke’s style will be overriden following the next draw cycle. The recommended method to set per-slice spoke styles is in SChartDelegate’s sChart:alterLabel:forDatapoint:atSliceIndex:inRadialSeries:

Declared In

SChartDonutSeries.h

setStyle:

Sets the style object for the donut series.

- (void)setStyle:(SChartDonutSeriesStyle *)style

Parameters

style

The new style object to use for the donut series.

See Also

Declared In

SChartDonutSeries.h

style

Manages the appearance of the donut series on the chart.

- (SChartDonutSeriesStyle *)style

Discussion

The default settings of the style are inherited from the chart theme. You can tweak the appearance of the series by modifying the style.

Declared In

SChartDonutSeries.h