Core Plot (macOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTLegend.h
Go to the documentation of this file.
1 #import "CPTBorderedLayer.h"
2 #import "CPTPlot.h"
3 
5 
6 @class CPTFill;
7 @class CPTLegend;
8 @class CPTLineStyle;
9 @class CPTTextStyle;
10 
15 
18 
22 extern CPTLegendNotification __nonnull const CPTLegendNeedsRedrawForPlotNotification NS_SWIFT_NAME(needsRedrawForPlot);
23 
27 extern CPTLegendNotification __nonnull const CPTLegendNeedsLayoutForPlotNotification NS_SWIFT_NAME(needsLayoutForPlot);
28 
32 extern CPTLegendNotification __nonnull const CPTLegendNeedsReloadEntriesForPlotNotification NS_SWIFT_NAME(needsReloadEntriesForPlot);
33 
35 
39 typedef NS_ENUM (NSInteger, CPTLegendSwatchLayout) {
44 };
45 
46 #pragma mark -
47 
52 
53 @optional
54 
57 
64 -(nullable CPTFill *)legend:(nonnull CPTLegend *)legend fillForEntryAtIndex:(NSUInteger)idx forPlot:(nonnull CPTPlot *)plot;
65 
72 -(nullable CPTLineStyle *)legend:(nonnull CPTLegend *)legend lineStyleForEntryAtIndex:(NSUInteger)idx forPlot:(nonnull CPTPlot *)plot;
73 
80 -(nullable CPTFill *)legend:(nonnull CPTLegend *)legend fillForSwatchAtIndex:(NSUInteger)idx forPlot:(nonnull CPTPlot *)plot;
81 
88 -(nullable CPTLineStyle *)legend:(nonnull CPTLegend *)legend lineStyleForSwatchAtIndex:(NSUInteger)idx forPlot:(nonnull CPTPlot *)plot;
89 
102 -(BOOL)legend:(nonnull CPTLegend *)legend shouldDrawSwatchAtIndex:(NSUInteger)idx forPlot:(nonnull CPTPlot *)plot inRect:(CGRect)rect inContext:(nonnull CGContextRef)context;
103 
105 
108 
118 -(void)legend:(nonnull CPTLegend *)legend legendEntryForPlot:(nonnull CPTPlot *)plot wasSelectedAtIndex:(NSUInteger)idx;
119 
130 -(void)legend:(nonnull CPTLegend *)legend legendEntryForPlot:(nonnull CPTPlot *)plot wasSelectedAtIndex:(NSUInteger)idx withEvent:(nonnull CPTNativeEvent *)event;
131 
141 -(void)legend:(nonnull CPTLegend *)legend legendEntryForPlot:(nonnull CPTPlot *)plot touchDownAtIndex:(NSUInteger)idx;
142 
153 -(void)legend:(nonnull CPTLegend *)legend legendEntryForPlot:(nonnull CPTPlot *)plot touchDownAtIndex:(NSUInteger)idx withEvent:(nonnull CPTNativeEvent *)event;
154 
164 -(void)legend:(nonnull CPTLegend *)legend legendEntryForPlot:(nonnull CPTPlot *)plot touchUpAtIndex:(NSUInteger)idx;
165 
176 -(void)legend:(nonnull CPTLegend *)legend legendEntryForPlot:(nonnull CPTPlot *)plot touchUpAtIndex:(NSUInteger)idx withEvent:(nonnull CPTNativeEvent *)event;
177 
179 
180 @end
181 
182 #pragma mark -
183 
185 
188 @property (nonatomic, readwrite, copy, nullable) CPTTextStyle *textStyle;
189 @property (nonatomic, readwrite, assign) CGSize swatchSize;
190 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *swatchBorderLineStyle;
191 @property (nonatomic, readwrite, assign) CGFloat swatchCornerRadius;
192 @property (nonatomic, readwrite, copy, nullable) CPTFill *swatchFill;
193 
194 @property (nonatomic, readwrite, copy, nullable) CPTLineStyle *entryBorderLineStyle;
195 @property (nonatomic, readwrite, assign) CGFloat entryCornerRadius;
196 @property (nonatomic, readwrite, copy, nullable) CPTFill *entryFill;
197 @property (nonatomic, readwrite, assign) CGFloat entryPaddingLeft;
198 @property (nonatomic, readwrite, assign) CGFloat entryPaddingTop;
199 @property (nonatomic, readwrite, assign) CGFloat entryPaddingRight;
200 @property (nonatomic, readwrite, assign) CGFloat entryPaddingBottom;
202 
205 @property (nonatomic, readonly) BOOL layoutChanged;
206 @property (nonatomic, readwrite, assign) NSUInteger numberOfRows;
207 @property (nonatomic, readwrite, assign) NSUInteger numberOfColumns;
208 @property (nonatomic, readwrite, assign) BOOL equalRows;
209 @property (nonatomic, readwrite, assign) BOOL equalColumns;
210 @property (nonatomic, readwrite, copy, nullable) CPTNumberArray *rowHeights;
211 @property (nonatomic, readonly, nullable) CPTNumberArray *rowHeightsThatFit;
212 @property (nonatomic, readwrite, copy, nullable) CPTNumberArray *columnWidths;
213 @property (nonatomic, readonly, nullable) CPTNumberArray *columnWidthsThatFit;
214 @property (nonatomic, readwrite, assign) CGFloat columnMargin;
215 @property (nonatomic, readwrite, assign) CGFloat rowMargin;
216 @property (nonatomic, readwrite, assign) CGFloat titleOffset;
217 @property (nonatomic, readwrite, assign) CPTLegendSwatchLayout swatchLayout;
219 
222 +(nonnull instancetype)legendWithPlots:(nullable CPTPlotArray *)newPlots;
223 +(nonnull instancetype)legendWithGraph:(nullable __kindof CPTGraph *)graph;
225 
228 -(nonnull instancetype)initWithPlots:(nullable CPTPlotArray *)newPlots;
229 -(nonnull instancetype)initWithGraph:(nullable __kindof CPTGraph *)graph;
231 
234 -(nonnull CPTPlotArray *)allPlots;
235 -(nullable CPTPlot *)plotAtIndex:(NSUInteger)idx;
236 -(nullable CPTPlot *)plotWithIdentifier:(nullable id<NSCopying>)identifier;
237 
238 -(void)addPlot:(nonnull CPTPlot *)plot;
239 -(void)insertPlot:(nonnull CPTPlot *)plot atIndex:(NSUInteger)idx;
240 -(void)removePlot:(nonnull CPTPlot *)plot;
241 -(void)removePlotWithIdentifier:(nullable id<NSCopying>)identifier;
243 
246 -(void)setLayoutChanged;
248 
249 @end
CPTLegend::equalColumns
BOOL equalColumns
If YES each column of legend entries will have the same width, otherwise columns will be sized to bes...
Definition: CPTLegend.h:209
CPTLineStyle
Immutable wrapper for various line drawing properties. Create a CPTMutableLineStyle if you want to cu...
Definition: CPTLineStyle.h:20
-[CPTLegend setLayoutChanged]
void setLayoutChanged()
Marks the receiver as needing to update the layout of its legend entries.
Definition: CPTLegend.m:793
CPTLegendSwatchLayout
CPTLegendSwatchLayout
Enumeration of legend layout options.
Definition: CPTLegend.h:39
NSEvent
CPTLegend::titleOffset
CGFloat titleOffset
The distance between each swatch and its title, specified in device units. Default is 5....
Definition: CPTLegend.h:216
CPTBorderedLayer.h
CPTLegend::numberOfRows
NSUInteger numberOfRows
The desired number of rows of legend entries. If zero (0) (the default), the number of rows will be a...
Definition: CPTLegend.h:206
NSUInteger
typedef NSUInteger
CPTLegend::entryBorderLineStyle
CPTLineStyle * entryBorderLineStyle
The line style for the border drawn around each legend entry. If nil (the default),...
Definition: CPTLegend.h:194
CPTLegend::rowHeights
CPTNumberArray * rowHeights
The desired height of each row of legend entries, including the swatch and title. Each element in thi...
Definition: CPTLegend.h:210
CPTTextStyle
Immutable wrapper for various text style properties.
Definition: CPTTextStyle.h:18
CPTLegend::entryPaddingRight
CGFloat entryPaddingRight
Amount to inset the swatch and title from the right side of the legend entry.
Definition: CPTLegend.h:199
CPTLegend::swatchFill
CPTFill * swatchFill
The background fill drawn behind each swatch. If nil (the default), no fill is drawn.
Definition: CPTLegend.h:192
CPTLegend::textStyle
CPTTextStyle * textStyle
The text style used to draw all legend entry titles.
Definition: CPTLegend.h:188
CPTLegend::entryCornerRadius
CGFloat entryCornerRadius
The corner radius for the border around each legend entry. Default is 0.0.
Definition: CPTLegend.h:195
CPTLegendNeedsReloadEntriesForPlotNotification
CPTLegendNotification __nonnull const CPTLegendNeedsReloadEntriesForPlotNotification
Notification sent by plots to tell the legend it should reload all legend entries.
Definition: CPTLegend.m:25
CPTFill
Draws area fills.
Definition: CPTFill.h:18
CPTLegendSwatchLayoutRight
@ CPTLegendSwatchLayoutRight
Lay out the swatch to the right side of the title.
Definition: CPTLegend.h:41
CPTLegend::entryPaddingTop
CGFloat entryPaddingTop
Amount to inset the swatch and title from the top of the legend entry.
Definition: CPTLegend.h:198
-[NSObject copy]
id copy
CPTLegend::entryFill
CPTFill * entryFill
The background fill drawn behind each legend entry. If nil (the default), no fill is drawn.
Definition: CPTLegend.h:196
CPTLayerDelegate-p
Layer delegate.
Definition: CPTLayer.h:76
CPTLegend::swatchCornerRadius
CGFloat swatchCornerRadius
The corner radius for each swatch. Default is 0.0.
Definition: CPTLegend.h:191
CPTLegend::rowHeightsThatFit
CPTNumberArray * rowHeightsThatFit
The computed best-fit height of each row of legend entries, including the swatch and title....
Definition: CPTLegend.h:211
BOOL
typedef BOOL
CPTLegendNeedsRedrawForPlotNotification
CPTLegendNotification __nonnull const CPTLegendNeedsRedrawForPlotNotification
Notification sent by plots to tell the legend it should redraw itself.
Definition: CPTLegend.m:23
CGContextRef
typedef CGContextRef
CPTLegendSwatchLayoutTop
@ CPTLegendSwatchLayoutTop
Lay out the swatch above the title.
Definition: CPTLegend.h:42
CPTLegend::swatchSize
CGSize swatchSize
The size of the graphical swatch. If swatchSize is (0.0, 0.0), swatches will be drawn using a square ...
Definition: CPTLegend.h:189
CPTLegend::entryPaddingLeft
CGFloat entryPaddingLeft
Amount to inset the swatch and title from the left side of the legend entry.
Definition: CPTLegend.h:197
CPTLegendSwatchLayoutBottom
@ CPTLegendSwatchLayoutBottom
Lay out the swatch below the title.
Definition: CPTLegend.h:43
CPTLegend
A graph legend.
Definition: CPTLegend.h:185
CPTLegend::swatchBorderLineStyle
CPTLineStyle * swatchBorderLineStyle
The line style for the border drawn around each swatch. If nil (the default), no border is drawn.
Definition: CPTLegend.h:190
CPTLegend::numberOfColumns
NSUInteger numberOfColumns
The desired number of columns of legend entries. If zero (0) (the default), the number of columns wil...
Definition: CPTLegend.h:207
CPTPlot.h
CPTPlot
An abstract plot class.
Definition: CPTPlot.h:258
CPTBorderedLayer
A layer with a border line and background fill.
Definition: CPTBorderedLayer.h:7
cpt_swift_struct
#define cpt_swift_struct
Marks a type definition to be imported into Swift as a structure.
Definition: CPTDefinitions.h:73
CPTLegendSwatchLayoutLeft
@ CPTLegendSwatchLayoutLeft
Lay out the swatch to the left side of the title.
Definition: CPTLegend.h:40
NSString
CPTLegend::columnMargin
CGFloat columnMargin
The margin between columns, specified in device units. Default is 10.0.
Definition: CPTLegend.h:214
CPTLegend::equalRows
BOOL equalRows
If YES (the default) each row of legend entries will have the same height, otherwise rows will be siz...
Definition: CPTLegend.h:208
CPTLegend::layoutChanged
BOOL layoutChanged
If YES, the legend layout needs to recalculated.
Definition: CPTLegend.h:205
CPTLegendNeedsLayoutForPlotNotification
CPTLegendNotification __nonnull const CPTLegendNeedsLayoutForPlotNotification
Notification sent by plots to tell the legend it should update its layout and redraw itself.
Definition: CPTLegend.m:24
CGRect
typedef CGRect
CPTLegend::rowMargin
CGFloat rowMargin
The margin between rows, specified in device units. Default is 5.0.
Definition: CPTLegend.h:215
CPTLegend::swatchLayout
CPTLegendSwatchLayout swatchLayout
Where to draw the legend swatch relative to the title. Default is CPTLegendSwatchLayoutLeft.
Definition: CPTLegend.h:217
CPTLegend::columnWidths
CPTNumberArray * columnWidths
The desired width of each column of legend entries, including the swatch, title, and title offset....
Definition: CPTLegend.h:212
CPTLegend::entryPaddingBottom
CGFloat entryPaddingBottom
Amount to inset the swatch and title from the bottom of the legend entry.
Definition: CPTLegend.h:200
CPTLegend::columnWidthsThatFit
CPTNumberArray * columnWidthsThatFit
The computed best-fit width of each column of legend entries, including the swatch,...
Definition: CPTLegend.h:213
-[CPTLegend allPlots]
nonnull CPTPlotArray * allPlots()
All plots associated with the legend.
Definition: CPTLegend.m:981
CPTGraph
An abstract graph class.
Definition: CPTGraph.h:74
CPTLegendDelegate-p
Legend delegate.
Definition: CPTLegend.h:51