Core Plot (iOS)
Cocoa plotting framework for Mac OS X and iOS
CPTBarPlot Class Reference

A two-dimensional bar plot. More...

#import <CPTBarPlot.h>

+ Inheritance diagram for CPTBarPlot:
+ Collaboration diagram for CPTBarPlot:

Public Class Methods

Factory Methods
(CPTBarPlot *) + tubularBarPlotWithColor:horizontalBars:
 Creates and returns a new CPTBarPlot instance initialized with a bar fill consisting of a linear gradient between black and the given color. More...
 
- Public Class Methods inherited from CPTPlot
(id+ nilData
 A unique marker object used in collections to indicate that the datasource returned nil. More...
 
- Public Class Methods inherited from CALayer
(id+ layer
 
- Public Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 

Public Instance Methods

Data Ranges
(CPTPlotRange *) - plotRangeEnclosingBars
 Computes a plot range that completely encloses all of the bars. More...
 
Initialization
(id- initWithFrame: [implementation]
 Initializes a newly allocated CPTBarPlot object with the provided frame rectangle. More...
 
User Interaction
(BOOL- pointingDeviceDownEvent:atPoint: [implementation]
 Informs the receiver that the user has touched the screen. More...
 
- Public Instance Methods inherited from CPTPlot
(CPTPlotRange *) - plotRangeForField:
 Determines the smallest plot range that fully encloses the data for a particular field. More...
 
(CPTPlotRange *) - plotRangeForCoordinate:
 Determines the smallest plot range that fully encloses the data for a particular coordinate. More...
 
(NSUInteger- dataIndexFromInteractionPoint:
 Determines the index of the data element that is under the given point. More...
 
(NSUInteger- numberOfFields
 Number of fields in a plot data record. More...
 
(NSArray *) - fieldIdentifiers
 Identifiers (enum values) identifying the fields. More...
 
(NSArray *) - fieldIdentifiersForCoordinate:
 The field identifiers that correspond to a particular coordinate. More...
 
(void) - setDataNeedsReloading
 Marks the receiver as needing the data source reloaded before the content is next drawn. More...
 
(void) - reloadData
 Reload all plot data from the data source immediately. More...
 
(void) - reloadDataIfNeeded
 Reload plot data from the data source only if the data cache is out of date. More...
 
(void) - reloadDataInIndexRange:
 Reload plot data in the given index range from the data source immediately. More...
 
(void) - insertDataAtIndex:numberOfRecords:
 Insert records into the plot data cache at the given index. More...
 
(void) - deleteDataInIndexRange:
 Delete records in the given index range from the plot data cache. More...
 
(CPTMutableNumericData *) - cachedNumbersForField:
 Retrieves an array of numbers from the cache. More...
 
(NSNumber *) - cachedNumberForField:recordIndex:
 Retrieves a single number from the cache. More...
 
(double) - cachedDoubleForField:recordIndex:
 Retrieves a single number from the cache. More...
 
(NSDecimal- cachedDecimalForField:recordIndex:
 Retrieves a single number from the cache. More...
 
(NSArray *) - cachedArrayForKey:
 Retrieves an array of values from the cache. More...
 
(id- cachedValueForKey:recordIndex:
 Retrieves a single value from the cache. More...
 
(void) - cacheNumbers:forField:
 Copies an array of numbers to the cache. More...
 
(void) - cacheNumbers:forField:atRecordIndex:
 Copies an array of numbers to replace a part of the cache. More...
 
(void) - cacheArray:forKey:
 Copies an array of arbitrary values to the cache. More...
 
(void) - cacheArray:forKey:atRecordIndex:
 Copies an array of arbitrary values to replace a part of the cache. More...
 
(void) - setNeedsRelabel
 Marks the receiver as needing to update all data labels before the content is next drawn. More...
 
(void) - relabel
 Updates the data labels in the labelIndexRange. More...
 
(void) - relabelIndexRange:
 Marks the receiver as needing to update a range of data labels before the content is next drawn. More...
 
(void) - repositionAllLabelAnnotations
 Repositions all existing label annotations. More...
 
(void) - positionLabelAnnotation:forIndex:
 Adjusts the position of the data label annotation for the plot point at the given index. More...
 
(NSUInteger- numberOfLegendEntries
 The number of legend entries provided by this plot. More...
 
(NSString *) - titleForLegendEntryAtIndex:
 The title text of a legend entry. More...
 
(NSAttributedString *) - attributedTitleForLegendEntryAtIndex:
 The styled title text of a legend entry. More...
 
(void) - drawSwatchForLegend:atIndex:inRect:inContext:
 Draws the legend swatch of a legend entry. Subclasses should call super to draw the background fill and border. More...
 
(id- numbersFromDataSourceForField:recordIndexRange:
 Gets a range of plot data for the given plot and field. More...
 
(BOOL- loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:
 Gets a range of plot data for the given plot. More...
 
- Public Instance Methods inherited from CPTAnnotationHostLayer
(void) - addAnnotation:
 Adds an annotation to the receiver. More...
 
(void) - removeAnnotation:
 Removes an annotation from the receiver. More...
 
(void) - removeAllAnnotations
 Removes all annotations from the receiver. More...
 
(BOOL- pointingDeviceUpEvent:atPoint: [implementation]
 Informs the receiver that the user has lifted their finger off the screen. More...
 
(BOOL- pointingDeviceDraggedEvent:atPoint: [implementation]
 Informs the receiver that the user has moved their finger while touching the screen. More...
 
(BOOL- pointingDeviceCancelledEvent: [implementation]
 Informs the receiver that tracking of touches has been cancelled for any reason. More...
 
- Public Instance Methods inherited from CPTLayer
(id- init [implementation]
 Initializes a newly allocated CPTLayer object with an empty frame rectangle. More...
 
(void) - logLayers
 Logs this layer and all of its sublayers. More...
 
(CPTNativeImage *) - imageOfLayer
 Gets an image of the layer contents. More...
 
(void) - renderAsVectorInContext:
 Draws layer content into the provided graphics context. More...
 
(void) - recursivelyRenderInContext:
 Draws layer content and the content of all sublayers into the provided graphics context. More...
 
(void) - layoutAndRenderInContext:
 Updates the layer layout if needed and then draws layer content and the content of all sublayers into the provided graphics context. More...
 
(NSData *) - dataForPDFRepresentationOfLayer
 Draws layer content and the content of all sublayers into a PDF document. More...
 
(void) - applySublayerMaskToContext:forSublayer:withOffset:
 Recursively sets the clipping path of the given graphics context to the sublayer masking paths of its superlayers. More...
 
(void) - applyMaskToContext:
 Sets the clipping path of the given graphics context to mask the content. More...
 
(void) - pixelAlign
 Align the receiver’s position with pixel boundaries. More...
 
(void) - sublayerMarginLeft:top:right:bottom:
 Returns the margins that should be left between the bounds of the receiver and all sublayers. More...
 
(void) - layoutSublayers [implementation]
 Updates the layout of all sublayers. Sublayers fill the super layer’s bounds minus any padding. More...
 
- Public Instance Methods inherited from CALayer
(BOOL- containsPoint:
 
(void) - drawInContext:
 
(id- init
 
(id- initWithLayer
 
(void) - layoutSublayers
 
(void) - setNeedsDisplay
 
(void) - setNeedsDisplayInRect:
 
(void) - setNeedsLayout
 
- Public Instance Methods inherited from NSObject
(Class- classForCoder
 
(id- copy
 
(void) - dealloc
 
(void) - finalize
 
(id- init
 
(id- mutableCopy
 
- Public Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
User Interaction

Properties

Appearance
BOOL barWidthsAreInViewCoordinates
 Whether the bar width and bar offset is in view coordinates, or in plot coordinates. Default is NO, meaning plot coordinates are used. More...
 
NSDecimal barWidth
 The width of each bar. Either view or plot coordinates can be used. More...
 
CGFloat barWidthScale
 An animatable scaling factor for the bar width. Default is 1.0. More...
 
NSDecimal barOffset
 The starting offset of the first bar in location data units. More...
 
CGFloat barOffsetScale
 An animatable scaling factor for the bar offset. Default is 1.0. More...
 
CGFloat barCornerRadius
 The corner radius for the end of the bars. Default is 0.0 for square corners. More...
 
CGFloat barBaseCornerRadius
 The corner radius for the end of the bars drawn at the base value. Default is 0.0 for square corners. More...
 
BOOL barsAreHorizontal
 If YES, the bars will have a horizontal orientation, otherwise they will be vertical. More...
 
NSDecimal baseValue
 The coordinate value of the fixed end of the bars. This is only used if barBasesVary is NO. Otherwise, the data source will be queried for an appropriate value of CPTBarPlotFieldBarBase. More...
 
BOOL barBasesVary
 If NO, a constant base value is used for all bars. If YES, the data source is queried to supply a base value for each bar. More...
 
CPTPlotRangeplotRange
 Sets the plot range for the independent axis. More...
 
Drawing
CPTLineStylelineStyle
 The line style for the bar outline. If nil, the outline is not drawn. More...
 
CPTFillfill
 The fill style for the bars. If nil, the bars are not filled. More...
 
- Properties inherited from CPTPlot
__cpt_weak id< CPTPlotDataSourcedataSource
 The data source for the plot. More...
 
NSStringtitle
 The title of the plot displayed in the legend. More...
 
NSAttributedStringattributedTitle
 The styled title of the plot displayed in the legend. More...
 
CPTPlotSpaceplotSpace
 The plot space for the plot. More...
 
CPTPlotAreaplotArea
 The plot area for the plot. More...
 
BOOL alignsPointsToPixels
 If YES (the default), all plot points will be aligned to device pixels when drawing. More...
 
BOOL dataNeedsReloading
 If YES, the plot data will be reloaded from the data source before the layer content is drawn. More...
 
NSUInteger cachedDataCount
 The number of data points stored in the cache. More...
 
BOOL doublePrecisionCache
 If YES, the cache holds data of type double, otherwise it holds NSDecimal. More...
 
CPTPlotCachePrecision cachePrecision
 The numeric precision used to cache the plot data and perform all plot calculations. Defaults to CPTPlotCachePrecisionAuto. More...
 
CPTNumericDataType doubleDataType
 The CPTNumericDataType used to cache plot data as double. More...
 
CPTNumericDataType decimalDataType
 The CPTNumericDataType used to cache plot data as NSDecimal. More...
 
BOOL needsRelabel
 If YES, the plot needs to be relabeled before the layer content is drawn. More...
 
BOOL adjustLabelAnchors
 If YES, data labels anchor points are adjusted automatically when the labels are positioned. If NO, data labels anchor points do not change. More...
 
BOOL showLabels
 Set to NO to override all other label settings and hide the data labels. Defaults to YES. More...
 
CGFloat labelOffset
 The distance that labels should be offset from their anchor points. The direction of the offset is defined by subclasses. More...
 
CGFloat labelRotation
 The rotation of the data labels in radians. Set this property to π/2 to have labels read up the screen, for example. More...
 
NSUInteger labelField
 The plot field identifier of the data field used to generate automatic labels. More...
 
CPTTextStylelabelTextStyle
 The text style used to draw the data labels. Set this property to nil to hide the data labels. More...
 
NSFormatterlabelFormatter
 The number formatter used to format the data labels. Set this property to nil to hide the data labels. If you need a non-numerical label, such as a date, you can use a formatter than turns the numerical plot coordinate into a string (e.g., “Jan 10, 2010”). The CPTCalendarFormatter and CPTTimeFormatter classes are useful for this purpose. More...
 
CPTShadowlabelShadow
 The shadow applied to each data label. More...
 
BOOL drawLegendSwatchDecoration
 If YES (the default), additional plot-specific decorations, symbols, and/or colors will be drawn on top of the legend swatch rectangle. More...
 
- Properties inherited from CPTAnnotationHostLayer
NSArrayannotations
 An array of annotations attached to this layer. More...
 
- Properties inherited from CPTLayer
__cpt_weak CPTGraphgraph
 The graph for the layer. More...
 
CGFloat paddingLeft
 Amount to inset the left side of each sublayer. More...
 
CGFloat paddingTop
 Amount to inset the top of each sublayer. More...
 
CGFloat paddingRight
 Amount to inset the right side of each sublayer. More...
 
CGFloat paddingBottom
 Amount to inset the bottom of each sublayer. More...
 
id< NSCopying, NSCoding, NSObjectidentifier
 An object used to identify the layer in collections. More...
 
CGFloat contentsScale
 The scale factor applied to the layer. More...
 
BOOL useFastRendering
 If YES, subclasses should optimize their drawing for speed over precision. More...
 
CPTShadowshadow
 The shadow drawn under the layer content. If nil (the default), no shadow is drawn. More...
 
CGSize shadowMargin
 The maximum margin size needed to fully enclose the layer shadow. More...
 
BOOL masksToBorder
 If YES, a sublayer mask is applied to clip sublayer content to the inside of the border. More...
 
CGPathRef outerBorderPath
 A drawing path that encompasses the outer boundary of the layer border. More...
 
CGPathRef innerBorderPath
 A drawing path that encompasses the inner boundary of the layer border. More...
 
CGPathRef maskingPath
 A drawing path that encompasses the layer content including any borders. Set to NULL when no masking is desired. More...
 
CGPathRef sublayerMaskingPath
 A drawing path that encompasses the layer content excluding any borders. Set to NULL when no masking is desired. More...
 
NSSetsublayersExcludedFromAutomaticLayout
 A set of sublayers that should be excluded from the automatic sublayer layout. More...
 
- Properties inherited from CALayer
CGPoint anchorPoint
 
CGRect bounds
 
CGFloat contentsScale
 
CGFloat cornerRadius
 
id delegate
 
CGRect frame
 
BOOL masksToBounds
 
BOOL needsDisplayOnBoundsChange
 
BOOL opacity
 
BOOL opaque
 
- Properties inherited from <CAMediaTiming>
BOOL autoreverses
 
CFTimeInterval beginTime
 
CFTimeInterval duration
 
NSStringfillMode
 
float repeatCount
 
id repeatDuration
 
float speed
 
CFTimeInterval timeOffset
 

Detailed Description

A two-dimensional bar plot.

See Also
See Bar Plot for a list of animatable properties.

Method Documentation

- (id) initWithFrame: (CGRect newFrame
implementation

Initializes a newly allocated CPTBarPlot object with the provided frame rectangle.

This is the designated initializer. The initialized layer will have the following properties:

Parameters
newFrameThe frame rectangle.
Returns
The initialized CPTBarPlot object.

Reimplemented from CPTPlot.

- (CPTPlotRange *) plotRangeEnclosingBars

Computes a plot range that completely encloses all of the bars.

For a horizontal bar plot, this range starts at the left edge of the first bar and continues to the right edge of the last bar. Similarly, this range starts at the bottom edge of the first bar and continues to the top edge of the last bar for vertical bar plots. The length will have the same sign as the corresponding plot range from the plot space.

Returns
A plot range that completely encloses all of the bars.
- (BOOL) pointingDeviceDownEvent: (CPTNativeEvent *)  event
atPoint: (CGPoint interactionPoint 
implementation

Informs the receiver that the user has touched the screen.

If this plot has a delegate that responds to the -barPlot:barWasSelectedAtRecordIndex: and/or -barPlot:barWasSelectedAtRecordIndex:withEvent: methods, the interactionPoint is compared with each bar in index order. The delegate method will be called and this method returns YES for the first index where the interactionPoint is inside a bar. This method returns NO if the interactionPoint is outside all of the bars.

Parameters
eventThe OS event.
interactionPointThe coordinates of the interaction.
Returns
Whether the event was handled or not.

Reimplemented from CPTPlot.

+ (CPTBarPlot *) tubularBarPlotWithColor: (CPTColor *)  color
horizontalBars: (BOOL horizontal 

Creates and returns a new CPTBarPlot instance initialized with a bar fill consisting of a linear gradient between black and the given color.

Parameters
colorThe beginning color.
horizontalIf YES, the bars will have a horizontal orientation, otherwise they will be vertical.
Returns
A new CPTBarPlot instance initialized with a linear gradient bar fill.

Property Documentation

- (BOOL) barBasesVary
readwritenonatomicassign

If NO, a constant base value is used for all bars. If YES, the data source is queried to supply a base value for each bar.

See Also
baseValue
- (NSDecimal) barOffset
readwritenonatomicassign

The starting offset of the first bar in location data units.

- (BOOL) barsAreHorizontal
readwritenonatomicassign

If YES, the bars will have a horizontal orientation, otherwise they will be vertical.

- (NSDecimal) barWidth
readwritenonatomicassign

The width of each bar. Either view or plot coordinates can be used.

With plot coordinates, the bar locations are one data unit apart (e.g., 1, 2, 3, etc.), a value of 1.0 will result in bars that touch each other; a value of 0.5 will result in bars that are as wide as the gap between them.

See Also
barWidthsAreInViewCoordinates
- (BOOL) barWidthsAreInViewCoordinates
readwritenonatomicassign

Whether the bar width and bar offset is in view coordinates, or in plot coordinates. Default is NO, meaning plot coordinates are used.

- (NSDecimal) baseValue
readwritenonatomicassign

The coordinate value of the fixed end of the bars. This is only used if barBasesVary is NO. Otherwise, the data source will be queried for an appropriate value of CPTBarPlotFieldBarBase.

- (CPTFill *) fill
readwritenonatomiccopy

The fill style for the bars. If nil, the bars are not filled.

- (CPTLineStyle *) lineStyle
readwritenonatomiccopy

The line style for the bar outline. If nil, the outline is not drawn.

- (CPTPlotRange *) plotRange
readwritenonatomiccopy

Sets the plot range for the independent axis.

If a plot range is provided, the bars are spaced evenly throughout the plot range. If plotRange is nil, bar locations are provided by Cocoa bindings or the bar plot datasource. If locations are not provided by either bindings or the datasource, the first bar will be placed at zero (0) and subsequent bars will be at successive positive integer coordinates.


The documentation for this class was generated from the following files: