Core Plot (macOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTPieChart.h
Go to the documentation of this file.
1 #import "CPTDefinitions.h"
2 #import "CPTFill.h"
3 #import "CPTPlot.h"
4 
6 
7 @class CPTColor;
8 @class CPTPieChart;
9 @class CPTTextLayer;
10 @class CPTLineStyle;
11 
16 
23 
27 typedef NS_ENUM (NSInteger, CPTPieChartField) {
31 };
32 
36 typedef NS_CLOSED_ENUM(NSInteger, CPTPieDirection) {
39 };
40 
41 #pragma mark -
42 
47 @optional
48 
51 
57 -(nullable CPTFillArray *)sliceFillsForPieChart:(nonnull CPTPieChart *)pieChart recordIndexRange:(NSRange)indexRange;
58 
68 -(nullable CPTFill *)sliceFillForPieChart:(nonnull CPTPieChart *)pieChart recordIndex:(NSUInteger)idx;
69 
71 
74 
80 -(nullable CPTNumberArray *)radialOffsetsForPieChart:(nonnull CPTPieChart *)pieChart recordIndexRange:(NSRange)indexRange;
81 
90 -(CGFloat)radialOffsetForPieChart:(nonnull CPTPieChart *)pieChart recordIndex:(NSUInteger)idx;
91 
93 
96 
102 -(nullable NSString *)legendTitleForPieChart:(nonnull CPTPieChart *)pieChart recordIndex:(NSUInteger)idx;
103 
109 -(nullable NSAttributedString *)attributedLegendTitleForPieChart:(nonnull CPTPieChart *)pieChart recordIndex:(NSUInteger)idx;
110 
112 @end
113 
114 #pragma mark -
115 
120 
121 @optional
122 
125 
134 -(void)pieChart:(nonnull CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)idx;
135 
145 -(void)pieChart:(nonnull CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)idx withEvent:(nonnull CPTNativeEvent *)event;
146 
155 -(void)pieChart:(nonnull CPTPieChart *)plot sliceTouchDownAtRecordIndex:(NSUInteger)idx;
156 
166 -(void)pieChart:(nonnull CPTPieChart *)plot sliceTouchDownAtRecordIndex:(NSUInteger)idx withEvent:(nonnull CPTNativeEvent *)event;
167 
176 -(void)pieChart:(nonnull CPTPieChart *)plot sliceTouchUpAtRecordIndex:(NSUInteger)idx;
177 
187 -(void)pieChart:(nonnull CPTPieChart *)plot sliceTouchUpAtRecordIndex:(NSUInteger)idx withEvent:(nonnull CPTNativeEvent *)event;
188 
190 
191 @end
192 
193 #pragma mark -
194 
195 @interface CPTPieChart : CPTPlot
196 
199 @property (nonatomic, readwrite) CGFloat pieRadius;
200 @property (nonatomic, readwrite) CGFloat pieInnerRadius;
201 @property (nonatomic, readwrite) CGFloat startAngle;
202 @property (nonatomic, readwrite) CGFloat endAngle;
203 @property (nonatomic, readwrite) CPTPieDirection sliceDirection;
204 @property (nonatomic, readwrite) CGPoint centerAnchor;
206 
209 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *borderLineStyle;
210 @property (nonatomic, readwrite, copy, nullable) CPTFill *overlayFill;
212 
215 @property (nonatomic, readwrite, assign) BOOL labelRotationRelativeToRadius;
217 
220 -(void)reloadSliceFills;
221 -(void)reloadSliceFillsInIndexRange:(NSRange)indexRange;
223 
226 -(void)reloadRadialOffsets;
227 -(void)reloadRadialOffsetsInIndexRange:(NSRange)indexRange;
229 
232 -(NSUInteger)pieSliceIndexAtAngle:(CGFloat)angle;
233 -(CGFloat)medianAngleForPieSliceIndex:(NSUInteger)idx;
235 
238 +(nonnull CPTColor *)defaultPieSliceColorForIndex:(NSUInteger)pieSliceIndex;
240 
241 @end
CPTPieChartDataSource-p
A pie chart data source.
Definition: CPTPieChart.h:46
CPTPieDirection
CPTPieDirection
Enumeration of pie slice drawing directions.
Definition: CPTPieChart.h:36
CPTPieChartFieldSliceWidthSum
@ CPTPieChartFieldSliceWidthSum
Cumulative sum of pie slice widths.
Definition: CPTPieChart.h:30
CPTLineStyle
Immutable wrapper for various line drawing properties. Create a CPTMutableLineStyle if you want to cu...
Definition: CPTLineStyle.h:20
CPTPieChart::pieRadius
CGFloat pieRadius
The radius of the overall pie chart. Defaults to 80% of the initial frame size.
Definition: CPTPieChart.h:199
-[CPTPieChart reloadSliceFills]
void reloadSliceFills()
Reload all slice fills from the data source immediately.
Definition: CPTPieChart.m:482
NSArray
CPTPieChartDelegate-p
Pie chart delegate.
Definition: CPTPieChart.h:119
CPTPlotDataSource-p
A plot data source.
Definition: CPTPlot.h:51
CPTPieChart::centerAnchor
CGPoint centerAnchor
The position of the center of the pie chart with the x and y coordinates given as a fraction of the w...
Definition: CPTPieChart.h:204
CPTPieChartBindingPieSliceWidthValues
CPTPieChartBinding __nonnull const CPTPieChartBindingPieSliceWidthValues
Pie slice widths.
Definition: CPTPieChart.m:28
CPTPieChart::endAngle
CGFloat endAngle
The ending angle for the last slice in radians. If NaN, the ending angle is the same as the start ang...
Definition: CPTPieChart.h:202
NSRange
typedef NSRange
CPTPieChart::borderLineStyle
CPTLineStyle * borderLineStyle
The line style used to outline the pie slices. If nil, no border is drawn. Defaults to nil.
Definition: CPTPieChart.h:209
CPTPieChartFieldSliceWidth
@ CPTPieChartFieldSliceWidth
Pie slice width.
Definition: CPTPieChart.h:28
NSUInteger
typedef NSUInteger
CPTPieChart
A pie chart.
Definition: CPTPieChart.h:196
-[CPTPieChart reloadRadialOffsets]
void reloadRadialOffsets()
Reload all slice offsets from the data source immediately.
Definition: CPTPieChart.m:534
CPTFill.h
CPTColor
An immutable color.
Definition: CPTColor.h:3
CPTPieChart::pieInnerRadius
CGFloat pieInnerRadius
The inner radius of the pie chart, used to create a “donut hole”. Defaults to 0.
Definition: CPTPieChart.h:200
CPTFill
Draws area fills.
Definition: CPTFill.h:18
-[NSObject copy]
id copy
NSAttributedString
CPTPieChart::startAngle
CGFloat startAngle
The starting angle for the first slice in radians. Defaults to π/2.
Definition: CPTPieChart.h:201
CPTDefinitions.h
CGFloat
typedef CGFloat
CPTPieChartBindingPieSliceRadialOffsets
CPTPieChartBinding __nonnull const CPTPieChartBindingPieSliceRadialOffsets
Pie slice radial offsets.
Definition: CPTPieChart.m:30
CPTPlot.h
CPTPieChartFieldSliceWidthNormalized
@ CPTPieChartFieldSliceWidthNormalized
Pie slice width normalized [0, 1].
Definition: CPTPieChart.h:29
CPTPlot
An abstract plot class.
Definition: CPTPlot.h:258
CPTPieChartField
CPTPieChartField
Enumeration of pie chart data source field types.
Definition: CPTPieChart.h:27
CPTPieDirectionClockwise
@ CPTPieDirectionClockwise
Pie slices are drawn in a clockwise direction.
Definition: CPTPieChart.h:37
CPTPieChart::overlayFill
CPTFill * overlayFill
A fill drawn on top of the pie chart. Can be used to add shading and/or gloss effects....
Definition: CPTPieChart.h:210
CPTTextLayer
A Core Animation layer that displays text drawn in a uniform style.
Definition: CPTTextLayer.h:9
cpt_swift_struct
#define cpt_swift_struct
Marks a type definition to be imported into Swift as a structure.
Definition: CPTDefinitions.h:73
NSString
CPTPieDirectionCounterClockwise
@ CPTPieDirectionCounterClockwise
Pie slices are drawn in a counter-clockwise direction.
Definition: CPTPieChart.h:38
CPTPlotDelegate-p
Plot delegate.
Definition: CPTPlot.h:170
CPTPieChartBindingPieSliceFills
CPTPieChartBinding __nonnull const CPTPieChartBindingPieSliceFills
Pie slice interior fills.
Definition: CPTPieChart.m:29
CPTPieChart::sliceDirection
CPTPieDirection sliceDirection
Determines whether the pie slices are drawn in a clockwise or counter-clockwise direction from the st...
Definition: CPTPieChart.h:203
CPTPieChart::labelRotationRelativeToRadius
BOOL labelRotationRelativeToRadius
If NO, the default, the data labels are rotated relative to the default coordinate system (the positi...
Definition: CPTPieChart.h:215