Core Plot (macOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTAxis.h
Go to the documentation of this file.
1 #import "CPTAxisLabel.h"
2 #import "CPTDefinitions.h"
3 #import "CPTFill.h"
4 #import "CPTLayer.h"
5 #import "CPTLimitBand.h"
6 #import "CPTPlotRange.h"
7 #import "CPTTextStyle.h"
8 
10 
11 @class CPTAxis;
12 @class CPTAxisSet;
13 @class CPTAxisTitle;
14 @class CPTGridLines;
15 @class CPTLineCap;
16 @class CPTLineStyle;
17 @class CPTPlotSpace;
18 @class CPTPlotArea;
19 @class CPTShadow;
20 
24 typedef NS_ENUM (NSInteger, CPTAxisLabelingPolicy) {
30 };
31 
36 
41 
42 #pragma mark -
43 
48 
49 @optional
50 
53 
58 -(BOOL)axisShouldRelabel:(nonnull CPTAxis *)axis;
59 
64 -(void)axisDidRelabel:(nonnull CPTAxis *)axis;
65 
73 -(BOOL)axis:(nonnull CPTAxis *)axis shouldUpdateAxisLabelsAtLocations:(nonnull CPTNumberSet *)locations;
74 
82 -(BOOL)axis:(nonnull CPTAxis *)axis shouldUpdateMinorAxisLabelsAtLocations:(nonnull CPTNumberSet *)locations;
83 
85 
88 
95 -(void)axis:(nonnull CPTAxis *)axis labelWasSelected:(nonnull CPTAxisLabel *)label;
96 
104 -(void)axis:(nonnull CPTAxis *)axis labelWasSelected:(nonnull CPTAxisLabel *)label withEvent:(nonnull CPTNativeEvent *)event;
105 
112 -(void)axis:(nonnull CPTAxis *)axis minorTickLabelWasSelected:(nonnull CPTAxisLabel *)label;
113 
121 -(void)axis:(nonnull CPTAxis *)axis minorTickLabelWasSelected:(nonnull CPTAxisLabel *)label withEvent:(nonnull CPTNativeEvent *)event;
122 
129 -(void)axis:(nonnull CPTAxis *)axis labelTouchDown:(nonnull CPTAxisLabel *)label;
130 
138 -(void)axis:(nonnull CPTAxis *)axis labelTouchDown:(nonnull CPTAxisLabel *)label withEvent:(nonnull CPTNativeEvent *)event;
139 
146 -(void)axis:(nonnull CPTAxis *)axis labelTouchUp:(nonnull CPTAxisLabel *)label;
147 
155 -(void)axis:(nonnull CPTAxis *)axis labelTouchUp:(nonnull CPTAxisLabel *)label withEvent:(nonnull CPTNativeEvent *)event;
156 
163 -(void)axis:(nonnull CPTAxis *)axis minorTickTouchDown:(nonnull CPTAxisLabel *)label;
164 
172 -(void)axis:(nonnull CPTAxis *)axis minorTickTouchDown:(nonnull CPTAxisLabel *)label withEvent:(nonnull CPTNativeEvent *)event;
173 
180 -(void)axis:(nonnull CPTAxis *)axis minorTickTouchUp:(nonnull CPTAxisLabel *)label;
181 
189 -(void)axis:(nonnull CPTAxis *)axis minorTickTouchUp:(nonnull CPTAxisLabel *)label withEvent:(nonnull CPTNativeEvent *)event;
190 
192 
193 @end
194 
195 #pragma mark -
196 
197 @interface CPTAxis : CPTLayer
198 
201 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *axisLineStyle;
202 @property (nonatomic, readwrite, assign) CPTCoordinate coordinate;
203 @property (nonatomic, readwrite, strong, nonnull) NSNumber *labelingOrigin;
204 @property (nonatomic, readwrite, assign) CPTSign tickDirection;
205 @property (nonatomic, readwrite, copy, nullable) CPTPlotRange *visibleRange;
206 @property (nonatomic, readwrite, copy, nullable) CPTPlotRange *visibleAxisRange;
207 @property (nonatomic, readwrite, copy, nullable) CPTLineCap *axisLineCapMin;
208 @property (nonatomic, readwrite, copy, nullable) CPTLineCap *axisLineCapMax;
210 
213 @property (nonatomic, readwrite, copy, nullable) CPTTextStyle *titleTextStyle;
214 @property (nonatomic, readwrite, strong, nullable) CPTAxisTitle *axisTitle;
215 @property (nonatomic, readwrite, assign) CGFloat titleOffset;
216 @property (nonatomic, readwrite, copy, nullable) NSString *title;
217 @property (nonatomic, readwrite, copy, nullable) NSAttributedString *attributedTitle;
218 @property (nonatomic, readwrite, assign) CGFloat titleRotation;
219 @property (nonatomic, readwrite, assign) CPTSign titleDirection;
220 @property (nonatomic, readwrite, strong, nullable) NSNumber *titleLocation;
221 @property (nonatomic, readonly, nonnull) NSNumber *defaultTitleLocation;
223 
226 @property (nonatomic, readwrite, assign) CPTAxisLabelingPolicy labelingPolicy;
227 @property (nonatomic, readwrite, assign) CGFloat labelOffset;
228 @property (nonatomic, readwrite, assign) CGFloat minorTickLabelOffset;
229 @property (nonatomic, readwrite, assign) CGFloat labelRotation;
230 @property (nonatomic, readwrite, assign) CGFloat minorTickLabelRotation;
231 @property (nonatomic, readwrite, assign) CPTAlignment labelAlignment;
232 @property (nonatomic, readwrite, assign) CPTAlignment minorTickLabelAlignment;
233 @property (nonatomic, readwrite, copy, nullable) CPTTextStyle *labelTextStyle;
234 @property (nonatomic, readwrite, copy, nullable) CPTTextStyle *minorTickLabelTextStyle;
235 @property (nonatomic, readwrite, assign) CPTSign tickLabelDirection;
236 @property (nonatomic, readwrite, assign) CPTSign minorTickLabelDirection;
237 @property (nonatomic, readwrite, strong, nullable) NSFormatter *labelFormatter;
238 @property (nonatomic, readwrite, strong, nullable) NSFormatter *minorTickLabelFormatter;
239 @property (nonatomic, readwrite, strong, nullable) CPTAxisLabelSet *axisLabels;
240 @property (nonatomic, readwrite, strong, nullable) CPTAxisLabelSet *minorTickAxisLabels;
241 @property (nonatomic, readonly) BOOL needsRelabel;
242 @property (nonatomic, readwrite, strong, nullable) CPTPlotRangeArray *labelExclusionRanges;
243 @property (nonatomic, readwrite, strong, nullable) CPTShadow *labelShadow;
244 @property (nonatomic, readwrite, strong, nullable) CPTShadow *minorTickLabelShadow;
246 
249 @property (nonatomic, readwrite, strong, nullable) NSNumber *majorIntervalLength;
250 @property (nonatomic, readwrite, assign) CGFloat majorTickLength;
251 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *majorTickLineStyle;
252 @property (nonatomic, readwrite, strong, nullable) CPTNumberSet *majorTickLocations;
253 @property (nonatomic, readwrite, assign) NSUInteger preferredNumberOfMajorTicks;
255 
258 @property (nonatomic, readwrite, assign) NSUInteger minorTicksPerInterval;
259 @property (nonatomic, readwrite, assign) CGFloat minorTickLength;
260 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *minorTickLineStyle;
261 @property (nonatomic, readwrite, strong, nullable) CPTNumberSet *minorTickLocations;
263 
266 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *majorGridLineStyle;
267 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *minorGridLineStyle;
268 @property (nonatomic, readwrite, copy, nullable) CPTPlotRange *gridLinesRange;
270 
273 @property (nonatomic, readwrite, copy, nullable) CPTFillArray *alternatingBandFills;
274 @property (nonatomic, readwrite, strong, nullable) NSNumber *alternatingBandAnchor;
275 @property (nonatomic, readonly, nullable) CPTLimitBandArray *backgroundLimitBands;
277 
280 @property (nonatomic, readwrite, strong, nullable) CPTPlotSpace *plotSpace;
282 
285 @property (nonatomic, readwrite, assign) BOOL separateLayers;
286 @property (nonatomic, readwrite, cpt_weak_property, nullable) CPTPlotArea *plotArea;
287 @property (nonatomic, readonly, cpt_weak_property, nullable) CPTGridLines *minorGridLines;
288 @property (nonatomic, readonly, cpt_weak_property, nullable) CPTGridLines *majorGridLines;
289 @property (nonatomic, readonly, nullable) CPTAxisSet *axisSet;
291 
294 -(void)updateAxisTitle;
296 
299 -(void)relabel;
300 -(void)setNeedsRelabel;
301 -(void)updateMajorTickLabels;
302 -(void)updateMinorTickLabels;
304 
307 -(nullable CPTNumberSet *)filteredMajorTickLocations:(nullable CPTNumberSet *)allLocations;
308 -(nullable CPTNumberSet *)filteredMinorTickLocations:(nullable CPTNumberSet *)allLocations;
310 
313 -(void)addBackgroundLimitBand:(nullable CPTLimitBand *)limitBand;
314 -(void)removeBackgroundLimitBand:(nullable CPTLimitBand *)limitBand;
317 
318 @end
319 
320 #pragma mark -
321 
326 
329 -(CGPoint)viewPointForCoordinateValue:(nullable NSNumber *)coordinateValue;
331 
334 -(void)drawGridLinesInContext:(nonnull CGContextRef)context isMajor:(BOOL)major;
336 
339 -(void)drawBackgroundBandsInContext:(nonnull CGContextRef)context;
340 -(void)drawBackgroundLimitsInContext:(nonnull CGContextRef)context;
342 
343 @end
-[CPTAxis updateMajorTickLabels]
void updateMajorTickLabels()
Update the major tick mark labels.
Definition: CPTAxis.m:1919
CPTShadow
Immutable wrapper for various shadow drawing properties.
Definition: CPTShadow.h:3
CPTAxis::minorTickLength
CGFloat minorTickLength
The length of the minor tick marks.
Definition: CPTAxis.h:259
-[CPTAxis relabel]
void relabel()
Updates the axis labels.
Definition: CPTAxis.m:1733
CPTAxis::labelingOrigin
NSNumber * labelingOrigin
The origin used for axis labels. The default value is 0. It is only used when the axis labeling polic...
Definition: CPTAxis.h:203
CPTAxis::titleTextStyle
CPTTextStyle * titleTextStyle
The text style used to draw the axis title text.
Definition: CPTAxis.h:213
CPTLineStyle
Immutable wrapper for various line drawing properties. Create a CPTMutableLineStyle if you want to cu...
Definition: CPTLineStyle.h:20
CPTAxis::plotSpace
CPTPlotSpace * plotSpace
The plot space for the axis.
Definition: CPTAxis.h:280
NSArray
CPTAxis::labelShadow
CPTShadow * labelShadow
The shadow applied to each axis label.
Definition: CPTAxis.h:243
CPTAxis::axisTitle
CPTAxisTitle * axisTitle
The axis title. If nil, no title is drawn.
Definition: CPTAxis.h:214
CPTAxis::attributedTitle
NSAttributedString * attributedTitle
A convenience property for setting the styled text title of the axis.
Definition: CPTAxis.h:217
CPTAxisLabelingPolicyNone
@ CPTAxisLabelingPolicyNone
No labels provided; user sets labels and tick locations.
Definition: CPTAxis.h:25
CPTAxis::titleDirection
CPTSign titleDirection
The offset direction for the axis title. The direction is given as the sign that ticks extend along t...
Definition: CPTAxis.h:219
CPTPlotRange.h
CPTTextStyle.h
CPTAxis::labelTextStyle
CPTTextStyle * labelTextStyle
The text style used to draw the label text.
Definition: CPTAxis.h:233
CPTLimitBand
Defines a range and fill used to highlight a band of data.
Definition: CPTLimitBand.h:17
CPTAxisLabel
An axis label.
Definition: CPTAxisLabel.h:19
CPTAxisLabelingPolicyEqualDivisions
@ CPTAxisLabelingPolicyEqualDivisions
Divide the plot range into equal parts.
Definition: CPTAxis.h:29
CPTAxis::backgroundLimitBands
CPTLimitBandArray * backgroundLimitBands
An array of CPTLimitBand objects.
Definition: CPTAxis.h:275
CPTAxis::minorTickLineStyle
CPTLineStyle * minorTickLineStyle
The line style for the minor tick marks. If nil, the minor ticks are not drawn.
Definition: CPTAxis.h:260
CPTAxis::labelingPolicy
CPTAxisLabelingPolicy labelingPolicy
The axis labeling policy.
Definition: CPTAxis.h:226
CPTAxis::tickLabelDirection
CPTSign tickLabelDirection
The offset direction for major tick labels. The direction is given as the sign that ticks extend alon...
Definition: CPTAxis.h:235
CPTAlignment
CPTAlignment
Label and constraint alignment constants.
Definition: CPTDefinitions.h:209
CPTPlotRange
Defines an immutable range of plot data.
Definition: CPTPlotRange.h:27
CPTAxis::axisLineCapMin
CPTLineCap * axisLineCapMin
The line cap for the end of the axis line with the minimum value.
Definition: CPTAxis.h:207
CGPoint
typedef CGPoint
-[CPTAxis updateMinorTickLabels]
void updateMinorTickLabels()
Update the minor tick mark labels.
Definition: CPTAxis.m:1938
CPTAxis(AbstractMethods)
CPTAxis abstract methods—must be overridden by subclasses.
Definition: CPTAxis.h:325
CPTAxis::visibleRange
CPTPlotRange * visibleRange
The plot range over which the axis and ticks are visible. Use this to restrict an axis and its grid l...
Definition: CPTAxis.h:205
CPTFill.h
CPTPlotSpace
Defines the coordinate system of a plot.
Definition: CPTPlotSpace.h:178
CPTAxis::plotArea
CPTPlotArea * plotArea
The plot area that the axis belongs to.
Definition: CPTAxis.h:286
CPTAxisTitle
An axis title.
Definition: CPTAxisTitle.h:4
CPTAxis::title
NSString * title
A convenience property for setting the text title of the axis.
Definition: CPTAxis.h:216
CPTTextStyle
Immutable wrapper for various text style properties.
Definition: CPTTextStyle.h:18
CPTAxisLabelingPolicyAutomatic
@ CPTAxisLabelingPolicyAutomatic
Automatic labeling policy.
Definition: CPTAxis.h:28
CPTAxis::minorGridLines
CPTGridLines * minorGridLines
The layer that draws the minor grid lines.
Definition: CPTAxis.h:287
CPTGridLines
An abstract class that draws grid lines for an axis.
Definition: CPTGridLines.h:6
CPTAxis::minorTickLabelDirection
CPTSign minorTickLabelDirection
The offset direction for minor tick labels. The direction is given as the sign that ticks extend alon...
Definition: CPTAxis.h:236
CPTAxis::titleOffset
CGFloat titleOffset
The offset distance between the axis title and the axis line.
Definition: CPTAxis.h:215
-[NSObject copy]
id copy
CPTLayerDelegate-p
Layer delegate.
Definition: CPTLayer.h:76
NSAttributedString
CPTAxis::labelOffset
CGFloat labelOffset
The offset distance between the tick marks and labels.
Definition: CPTAxis.h:227
CPTAxis::minorTickLabelShadow
CPTShadow * minorTickLabelShadow
The shadow applied to each minor tick axis label.
Definition: CPTAxis.h:244
CPTAxisLabelingPolicyLocationsProvided
@ CPTAxisLabelingPolicyLocationsProvided
User sets tick locations; axis makes labels.
Definition: CPTAxis.h:26
CPTAxis::minorTickLabelTextStyle
CPTTextStyle * minorTickLabelTextStyle
The text style used to draw the label text of minor tick labels.
Definition: CPTAxis.h:234
CPTAxis::minorTickLabelRotation
CGFloat minorTickLabelRotation
The rotation of the axis minor tick labels in radians. Set this property to π/2 to have labels read u...
Definition: CPTAxis.h:230
CPTMutableAxisArray
NSMutableArray< __kindof CPTAxis * > CPTMutableAxisArray
A mutable array of axes.
Definition: CPTAxis.h:40
CPTSign
CPTSign
Enumeration of label positioning offset directions.
Definition: CPTDefinitions.h:185
CPTAxis::labelRotation
CGFloat labelRotation
The rotation of the axis labels in radians. Set this property to π/2 to have labels read up the scree...
Definition: CPTAxis.h:229
CPTAxis::minorGridLineStyle
CPTLineStyle * minorGridLineStyle
The line style for the minor grid lines. If nil, the minor grid lines are not drawn.
Definition: CPTAxis.h:267
CPTAxis::gridLinesRange
CPTPlotRange * gridLinesRange
The plot range over which the grid lines are visible. Note that this range applies to the orthogonal ...
Definition: CPTAxis.h:268
CPTAxis::minorTickLabelOffset
CGFloat minorTickLabelOffset
The offset distance between the minor tick marks and labels.
Definition: CPTAxis.h:228
BOOL
typedef BOOL
CPTAxis::minorTickAxisLabels
CPTAxisLabelSet * minorTickAxisLabels
The set of minor tick axis labels.
Definition: CPTAxis.h:240
CPTAxis::majorGridLineStyle
CPTLineStyle * majorGridLineStyle
The line style for the major grid lines. If nil, the major grid lines are not drawn.
Definition: CPTAxis.h:266
CGContextRef
typedef CGContextRef
CPTAxis::majorIntervalLength
NSNumber * majorIntervalLength
The distance between major tick marks expressed in data coordinates.
Definition: CPTAxis.h:249
CPTAxis::alternatingBandAnchor
NSNumber * alternatingBandAnchor
The starting location of the first band fill.
Definition: CPTAxis.h:274
CPTLineCap
End cap decorations for lines.
Definition: CPTLineCap.h:25
CPTAxis::labelAlignment
CPTAlignment labelAlignment
The alignment of the axis label with respect to the tick mark.
Definition: CPTAxis.h:231
CPTLayer
Base class for all Core Animation layers in Core Plot.
Definition: CPTLayer.h:83
CPTDefinitions.h
CPTAxis::defaultTitleLocation
NSNumber * defaultTitleLocation
The position along the axis where the axis title should be centered if titleLocation is NaN.
Definition: CPTAxis.h:221
CPTAxisLabelingPolicy
CPTAxisLabelingPolicy
Enumeration of labeling policies.
Definition: CPTAxis.h:24
CPTAxis::minorTickLocations
CPTNumberSet * minorTickLocations
A set of axis coordinates for all minor tick marks.
Definition: CPTAxis.h:261
-[CPTAxis updateAxisTitle]
void updateAxisTitle()
Update the axis title position.
Definition: CPTAxis.m:1965
CPTAxis::visibleAxisRange
CPTPlotRange * visibleAxisRange
The plot range over which the axis itself is visible. Use this to restrict an axis line to less than ...
Definition: CPTAxis.h:206
CPTAxis::majorTickLength
CGFloat majorTickLength
The length of the major tick marks.
Definition: CPTAxis.h:250
CPTLimitBand.h
CPTAxis::axisLineCapMax
CPTLineCap * axisLineCapMax
The line cap for the end of the axis line with the maximum value.
Definition: CPTAxis.h:208
CPTAxis::axisLabels
CPTAxisLabelSet * axisLabels
The set of axis labels.
Definition: CPTAxis.h:239
CPTAxis::titleLocation
NSNumber * titleLocation
The position along the axis where the axis title should be centered. If NaN (the default),...
Definition: CPTAxis.h:220
CPTAxis::alternatingBandFills
CPTFillArray * alternatingBandFills
An array of two or more fills to be drawn between successive major tick marks.
Definition: CPTAxis.h:273
CPTAxis::labelExclusionRanges
CPTPlotRangeArray * labelExclusionRanges
An array of CPTPlotRange objects. Any tick marks and labels falling inside any of the ranges in the a...
Definition: CPTAxis.h:242
CPTCoordinate
CPTCoordinate
Enumeration of axis coordinates.
Definition: CPTDefinitions.h:164
CPTAxis::coordinate
CPTCoordinate coordinate
The axis coordinate.
Definition: CPTAxis.h:202
-[CPTAxis removeAllBackgroundLimitBands]
void removeAllBackgroundLimitBands()
Remove all background limit bands.
Definition: CPTAxis.m:2041
CPTAxis::needsRelabel
BOOL needsRelabel
If YES, the axis needs to be relabeled before the layer content is drawn.
Definition: CPTAxis.h:241
CPTAxisLabel.h
CPTAxis::axisSet
CPTAxisSet * axisSet
The axis set that the axis belongs to.
Definition: CPTAxis.h:289
CPTAxis::labelFormatter
NSFormatter * labelFormatter
The number formatter used to format the label text. If you need a non-numerical label,...
Definition: CPTAxis.h:237
CPTPlotArea
A layer representing the actual plotting area of a graph.
Definition: CPTPlotArea.h:76
NSString
CPTLayer.h
cpt_weak_property
#define cpt_weak_property
A custom definition for automatic reference counting (ARC) weak properties that falls back to assign ...
Definition: CPTDefinitions.h:32
CPTAxis::axisLineStyle
CPTLineStyle * axisLineStyle
The line style for the axis line. If nil, the line is not drawn.
Definition: CPTAxis.h:201
CPTAxis::tickDirection
CPTSign tickDirection
The tick direction. The direction is given as the sign that ticks extend along the axis (e....
Definition: CPTAxis.h:204
CPTAxis::separateLayers
BOOL separateLayers
Use separate layers for drawing grid lines?
Definition: CPTAxis.h:285
CPTAxisDelegate-p
Axis labeling delegate.
Definition: CPTAxis.h:47
CPTAxis::majorGridLines
CPTGridLines * majorGridLines
The layer that draws the major grid lines.
Definition: CPTAxis.h:288
CPTAxis::titleRotation
CGFloat titleRotation
The rotation angle of the axis title in radians. If NaN (the default), the title will be parallel to ...
Definition: CPTAxis.h:218
CPTAxis::preferredNumberOfMajorTicks
NSUInteger preferredNumberOfMajorTicks
The number of ticks that should be targeted when auto-generating positions. This property only applie...
Definition: CPTAxis.h:253
CPTAxis::majorTickLocations
CPTNumberSet * majorTickLocations
A set of axis coordinates for all major tick marks.
Definition: CPTAxis.h:252
CPTAxis::minorTicksPerInterval
NSUInteger minorTicksPerInterval
The number of minor tick marks drawn in each major tick interval.
Definition: CPTAxis.h:258
CPTAxisLabelingPolicyFixedInterval
@ CPTAxisLabelingPolicyFixedInterval
Fixed interval labeling policy.
Definition: CPTAxis.h:27
CPTAxisArray
NSArray< __kindof CPTAxis * > CPTAxisArray
An array of axes.
Definition: CPTAxis.h:35
CPTAxisSet
A container layer for the set of axes for a graph.
Definition: CPTAxisSet.h:7
CPTAxis::minorTickLabelAlignment
CPTAlignment minorTickLabelAlignment
The alignment of the axis label with respect to the tick mark.
Definition: CPTAxis.h:232
CPTAxis::majorTickLineStyle
CPTLineStyle * majorTickLineStyle
The line style for the major tick marks. If nil, the major ticks are not drawn.
Definition: CPTAxis.h:251
CPTAxis::minorTickLabelFormatter
NSFormatter * minorTickLabelFormatter
The number formatter used to format the label text of minor ticks. If you need a non-numerical label,...
Definition: CPTAxis.h:238
CPTAxis
An abstract axis class.
Definition: CPTAxis.h:198
-[CPTAxis setNeedsRelabel]
void setNeedsRelabel()
Marks the receiver as needing to update the labels before the content is next drawn.
Definition: CPTAxis.m:1725