|
| 1 | +// |
| 2 | +// JBBarChartView.h |
| 3 | +// JBChartView |
| 4 | +// |
| 5 | +// Created by Terry Worona on 9/3/13. |
| 6 | +// Copyright (c) 2013 Jawbone. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +// Views |
| 10 | +#import "JBChartView.h" |
| 11 | + |
| 12 | +@protocol JBBarChartViewDelegate; |
| 13 | +@protocol JBBarChartViewDataSource; |
| 14 | + |
| 15 | +@interface JBBarChartView : JBChartView |
| 16 | + |
| 17 | +@property (nonatomic, weak) id<JBBarChartViewDelegate> delegate; |
| 18 | +@property (nonatomic, weak) id<JBBarChartViewDataSource> dataSource; |
| 19 | + |
| 20 | +/** |
| 21 | + * If showsSelection is YES, a vertical highlight will overlayed on a bar during touch events. |
| 22 | + * By default, showsSelection is YES. |
| 23 | + */ |
| 24 | +@property (nonatomic, assign) BOOL showsSelection; |
| 25 | + |
| 26 | +@end |
| 27 | + |
| 28 | +@protocol JBBarChartViewDelegate <NSObject> |
| 29 | + |
| 30 | +/** |
| 31 | + * Height for a bar at a given index (left to right). There is no ceiling on the the height; |
| 32 | + * the chart will automatically normalize all values between the overal min and max heights. |
| 33 | + * |
| 34 | + * @param barChartView The origin chart |
| 35 | + * @param index The 0-based index of a given bar (left to right, x-axis) |
| 36 | + * |
| 37 | + * @return The y-axis height of the supplied bar index (x-axis) |
| 38 | + */ |
| 39 | +- (NSInteger)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index; |
| 40 | + |
| 41 | +@optional |
| 42 | + |
| 43 | +/** |
| 44 | + * Occurs when a touch gesture event occurs on a given bar. The chart must be expanded, showsSelection must be YES, |
| 45 | + * and the selection must occur within the bounds of the chart. |
| 46 | + * |
| 47 | + * @param barChartView The origin chart |
| 48 | + * @param index The 0-based index of a given bar (left to right, x-axis) |
| 49 | + */ |
| 50 | +- (void)barChartView:(JBBarChartView *)barChartView didSelectBarAtIndex:(NSInteger)index; |
| 51 | + |
| 52 | +/** |
| 53 | + * Occurs when selection ends by either ending a touch event or selecting an area that is outside the view's bounds. |
| 54 | + * For selection start events, see: didSelectBarAtIndex... |
| 55 | + * |
| 56 | + * @param barChartView The origin chart |
| 57 | + */ |
| 58 | +- (void)didUnselectBarChartView:(JBBarChartView *)barChartView; |
| 59 | + |
| 60 | +@end |
| 61 | + |
| 62 | +@protocol JBBarChartViewDataSource <NSObject> |
| 63 | + |
| 64 | +/** |
| 65 | + * The number of bars in a given bar chart is the number of vertical views shown along the x-axis. |
| 66 | + * |
| 67 | + * @param barChartView The origin chart |
| 68 | + * |
| 69 | + * @return Number of bars in the given chart, displayed horizontally along the chart's x-axis. |
| 70 | + */ |
| 71 | +- (NSInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView; |
| 72 | + |
| 73 | +@optional |
| 74 | + |
| 75 | +/** |
| 76 | + * Horizontal padding between bars. By default, the chart will use a 'best-guess' algorithm |
| 77 | + * based on the the total number of bars and width of the chart. |
| 78 | + * |
| 79 | + * @param barChartView The origin chart |
| 80 | + * |
| 81 | + * @return Horizontal width (in pixels) between each bar. |
| 82 | + */ |
| 83 | +- (NSInteger)barPaddingForBarChartView:(JBBarChartView *)barChartView; |
| 84 | + |
| 85 | +/** |
| 86 | + * The color of all bars within the chart. |
| 87 | + * |
| 88 | + * @param barChartView The origin chart |
| 89 | + * @param index The 0-based index of a given bar (left to right, x-axis) |
| 90 | + * |
| 91 | + * @return The color to be used on each of the bars within the chart. |
| 92 | + */ |
| 93 | +- (UIColor *)barColorForBarChartView:(JBBarChartView *)barChartView atIndex:(NSInteger)index; |
| 94 | + |
| 95 | +/** |
| 96 | + * The selection color to be overlayed on a bar during touch events. |
| 97 | + * The color is automically faded to transparent (vertically). |
| 98 | + * |
| 99 | + * @param barChartView The origin chart |
| 100 | + * |
| 101 | + * @return The color to be used on each bar selection. |
| 102 | + */ |
| 103 | +- (UIColor *)selectionBarColorForBarChartView:(JBBarChartView *)barChartView; |
| 104 | + |
| 105 | +@end |
0 commit comments