Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7927cddb7 | |||
| 0f2d4d766c | |||
| 64de3e6e23 | |||
| 87fb8ee7b8 | |||
| 7c0dfe3eb5 | |||
| 87b62ad2b1 | |||
| 9c0d788418 | |||
| de009f0236 | |||
| d46e4fe14d | |||
| 236336fdf3 | |||
| 9b60a1d662 | |||
| 3700b4e2e2 | |||
| 8c03033a1c | |||
| bb084b1b89 | |||
| 1c7c8b2e52 | |||
| 79a57d98e3 | |||
| 20d6b6081b | |||
| 20bbbdcc86 | |||
| 51ac8a1d63 | |||
| 68d04a2cdb | |||
| b7734ef189 | |||
| f6d2fe8b62 | |||
| 5c9679f448 | |||
| 037225a386 | |||
| 0fe979bd22 | |||
| 31b64ed7e4 | |||
| c30398c3ea | |||
| bc08322a3a | |||
| 213973f4ed | |||
| 28d40bcb31 | |||
| d4df0184a2 | |||
| 4f313aab80 | |||
| b6262462c5 | |||
| 1080089753 | |||
| 0afba01a9a | |||
| 63b47667ec | |||
| 4d6baf066f | |||
| 359ef7d0ea | |||
| 7b1e6475f2 | |||
| 2b8853780c | |||
| 0754e2e5d2 | |||
| 52b722013e | |||
| 4ef9b6442e | |||
| 177e076807 | |||
| 21969d759d | |||
| 4fd6f1cb63 | |||
| 804ce2ca67 | |||
| 485cfb9631 | |||
| 4640dede3a | |||
| 1b90c6e16f | |||
| 15b53aa68e | |||
| 0e277dc347 | |||
| 6de42998c0 | |||
| a1e4be3a5d | |||
| acaf6fb4dc | |||
| 5894610278 | |||
| e605e60f28 | |||
| 33b3c9518f | |||
| aec3d31e17 | |||
| c99a0429b4 | |||
| f9fc90244f | |||
| 6b0198f732 | |||
| f0e52b42d7 | |||
| 381850ada4 | |||
| 8b22d5fadd | |||
| 01171b9487 | |||
| d3a1ce1c25 | |||
| 3b6863786f | |||
| 1d39945e62 |
+114
@@ -0,0 +1,114 @@
|
||||
# Changelog
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.2">2.4.2</a>
|
||||
#### 04/30/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/46">#46</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.1">2.4.1</a>
|
||||
#### 04/30/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/45">#45</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.0">2.4.0</a>
|
||||
#### 04/28/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/23">#23</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.3.0">2.3.0</a>
|
||||
#### 04/17/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/34">#34</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.2.0">2.2.0</a>
|
||||
#### 04/14/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/37">#37</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.6">2.1.6</a>
|
||||
#### 04/11/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/33">#33</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.5">2.1.5</a>
|
||||
#### 04/10/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/30">#30</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.4">2.1.4</a>
|
||||
#### 04/10/14
|
||||
- Added ability to specify a radius for dotted lines.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.3">2.1.3</a>
|
||||
#### 04/03/14
|
||||
- Added the ability to force a chart's state.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.2">2.1.2</a>
|
||||
#### 04/02/14
|
||||
- Added dynamic padding to JBLineChartView (based on max line width).
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.1">2.1.1</a>
|
||||
#### 04/02/14
|
||||
- Fixed minimumValue and maximumValue getter functions.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.0">2.1.0</a>
|
||||
#### 03/30/14
|
||||
- Added minimumValue and maximumValue properties.
|
||||
- Changed default min value implementation from 0 to chart's actual minimum value.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.0.2">2.0.2</a>
|
||||
#### 03/27/14
|
||||
- Added the ability to add point dots for lines in JBLineChartView.
|
||||
- Streamlined line styling.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.0.1">2.0.1</a>
|
||||
#### 03/19/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/22">#22</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.0.0">2.0.0</a>
|
||||
#### 03/18/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/21">#21</a>.
|
||||
- Added multi-line support for JBLineChartView.
|
||||
- Added position delegation on touch events.
|
||||
- Added tooltip views (demo-only).
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.6">1.1.6</a>
|
||||
#### 03/02/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/15">#15</a>.
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/14">#14</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.5">1.1.5</a>
|
||||
#### 02/11/14
|
||||
- Chart selection improvements.
|
||||
- Animation performance improvements.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.4">1.1.4</a>
|
||||
#### 02/06/14
|
||||
- Fixed compilation warnings.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.3">1.1.3</a>
|
||||
#### 01/06/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/11">#11</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.2">1.1.2</a>
|
||||
#### 01/03/14
|
||||
- Added CGFloat support for chart heights intead of integers.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.1">1.1.1</a>
|
||||
#### 01/02/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/7">#7</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.0">1.1.0</a>
|
||||
#### 12/26/13
|
||||
- Updated JBBarChartView datasource to request UIView subclasses for bars.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0.3">1.0.3</a>
|
||||
#### 12/23/13
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/4">#4</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0.2">1.0.2</a>
|
||||
#### 12/17/13
|
||||
- Additional fixes for issue <a href="https://github.com/Jawbone/JBChartView/pull/2">#2</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0.1">1.0.1</a>
|
||||
#### (12/14/13)
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/2">#2</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0">1.0</a>
|
||||
#### 12/10/13
|
||||
- Initial public release.
|
||||
- Base line and bar charts.
|
||||
- Basic customization; color, positioning, selections.
|
||||
+75
-21
@@ -10,7 +10,7 @@
|
||||
|
||||
// Numerics
|
||||
CGFloat static const kJBBarChartViewBarBasePaddingMutliplier = 50.0f;
|
||||
CGFloat static const kJBBarChartViewUndefinedMaxHeight = -1.0f;
|
||||
CGFloat static const kJBBarChartViewUndefinedCachedHeight = -1.0f;
|
||||
CGFloat static const kJBBarChartViewStateAnimationDuration = 0.05f;
|
||||
CGFloat static const kJBBarChartViewPopOffset = 10.0f; // used to offset bars for 'pop' animations
|
||||
NSInteger static const kJBBarChartViewUndefinedBarIndex = -1;
|
||||
@@ -24,6 +24,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
@property (nonatomic, strong) NSArray *barViews;
|
||||
@property (nonatomic, assign) CGFloat barPadding;
|
||||
@property (nonatomic, assign) CGFloat cachedMaxHeight;
|
||||
@property (nonatomic, assign) CGFloat cachedMinHeight;
|
||||
@property (nonatomic, strong) JBChartVerticalSelectionView *verticalSelectionView;
|
||||
@property (nonatomic, assign) BOOL verticalSelectionViewVisible;
|
||||
|
||||
@@ -33,8 +34,8 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
// View quick accessors
|
||||
- (CGFloat)availableHeight;
|
||||
- (CGFloat)normalizedHeightForRawHeight:(NSNumber*)rawHeight;
|
||||
- (CGFloat)maxHeight;
|
||||
- (CGFloat)minHeight;
|
||||
- (CGFloat)maxHeight;
|
||||
- (CGFloat)barWidth;
|
||||
- (CGFloat)popOffset;
|
||||
|
||||
@@ -93,9 +94,9 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
|
||||
- (void)construct
|
||||
{
|
||||
self.clipsToBounds = YES;
|
||||
_showsVerticalSelection = YES;
|
||||
_cachedMaxHeight = kJBBarChartViewUndefinedMaxHeight;
|
||||
_cachedMinHeight = kJBBarChartViewUndefinedCachedHeight;
|
||||
_cachedMaxHeight = kJBBarChartViewUndefinedCachedHeight;
|
||||
}
|
||||
|
||||
#pragma mark - Memory Management
|
||||
@@ -110,7 +111,8 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
- (void)reloadData
|
||||
{
|
||||
// reset cached max height
|
||||
self.cachedMaxHeight = kJBBarChartViewUndefinedMaxHeight;
|
||||
self.cachedMinHeight = kJBBarChartViewUndefinedCachedHeight;
|
||||
self.cachedMaxHeight = kJBBarChartViewUndefinedCachedHeight;
|
||||
|
||||
/*
|
||||
* The data collection holds all position information:
|
||||
@@ -128,7 +130,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
for (NSUInteger index=0; index<dataCount; index++)
|
||||
{
|
||||
CGFloat height = [self.delegate barChartView:self heightForBarViewAtAtIndex:index];
|
||||
NSAssert(height > 0, @"JBBarChartView // datasource function - (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index must return a CGFloat >= 0");
|
||||
NSAssert(height >= 0, @"JBBarChartView // datasource function - (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index must return a CGFloat >= 0");
|
||||
[dataDictionary setObject:[NSNumber numberWithFloat:height] forKey:[NSNumber numberWithInt:(int)index]];
|
||||
}
|
||||
self.chartDataDictionary = [NSDictionary dictionaryWithDictionary:dataDictionary];
|
||||
@@ -236,6 +238,9 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
// Position header and footer
|
||||
self.headerView.frame = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, self.headerView.frame.size.height);
|
||||
self.footerView.frame = CGRectMake(self.bounds.origin.x, self.bounds.size.height - self.footerView.frame.size.height, self.bounds.size.width, self.footerView.frame.size.height);
|
||||
|
||||
// Refresh state
|
||||
[self setState:self.state animated:NO callback:nil force:YES];
|
||||
}
|
||||
|
||||
#pragma mark - View Quick Accessors
|
||||
@@ -259,20 +264,22 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
return ((value - minHeight) / (maxHeight - minHeight)) * [self availableHeight];
|
||||
}
|
||||
|
||||
- (CGFloat)maxHeight
|
||||
{
|
||||
if (self.cachedMaxHeight == kJBBarChartViewUndefinedMaxHeight)
|
||||
{
|
||||
// max height is max value across all goals and values
|
||||
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
|
||||
self.cachedMaxHeight = [[chartValues lastObject] floatValue];
|
||||
}
|
||||
return self.cachedMaxHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)minHeight
|
||||
{
|
||||
return 0;
|
||||
if (self.mininumValue != kJBChartViewUndefinedMinimumValue)
|
||||
{
|
||||
return MIN(self.mininumValue, self.cachedMinHeight);
|
||||
}
|
||||
return self.cachedMinHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)maxHeight
|
||||
{
|
||||
if (self.maximumValue != kJBChartViewUndefinedMaximumValue)
|
||||
{
|
||||
return MAX(self.maximumValue, self.cachedMaxHeight);
|
||||
}
|
||||
return self.cachedMaxHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)barWidth
|
||||
@@ -294,9 +301,9 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback force:(BOOL)force
|
||||
{
|
||||
[super setState:state animated:animated callback:callback];
|
||||
[super setState:state animated:animated callback:callback force:force];
|
||||
|
||||
dispatch_block_t callbackCopy = [callback copy];
|
||||
|
||||
@@ -351,7 +358,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
{
|
||||
callbackCopy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -362,6 +369,53 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback
|
||||
{
|
||||
[self setState:state animated:animated callback:callback force:NO];
|
||||
}
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (CGFloat)cachedMinHeight
|
||||
{
|
||||
if(_cachedMinHeight == kJBBarChartViewUndefinedCachedHeight)
|
||||
{
|
||||
// min height is min value across all goals and values
|
||||
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
|
||||
_cachedMinHeight = [[chartValues firstObject] floatValue];
|
||||
}
|
||||
return _cachedMinHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)cachedMaxHeight
|
||||
{
|
||||
if (_cachedMaxHeight == kJBBarChartViewUndefinedCachedHeight)
|
||||
{
|
||||
// max height is max value across all goals and values
|
||||
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
|
||||
_cachedMaxHeight = [[chartValues lastObject] floatValue];
|
||||
}
|
||||
return _cachedMaxHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)mininumValue
|
||||
{
|
||||
if ([super mininumValue] == kJBChartViewUndefinedMinimumValue)
|
||||
{
|
||||
return self.cachedMinHeight;
|
||||
}
|
||||
return [super mininumValue];
|
||||
}
|
||||
|
||||
- (CGFloat)maximumValue
|
||||
{
|
||||
if ([super maximumValue] == kJBChartViewUndefinedMaximumValue)
|
||||
{
|
||||
return self.cachedMaxHeight;
|
||||
}
|
||||
return [super maximumValue];
|
||||
}
|
||||
|
||||
#pragma mark - Touch Helpers
|
||||
|
||||
- (NSInteger)barViewIndexForPoint:(CGPoint)point
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern CGFloat const kJBChartViewDefaultAnimationDuration;
|
||||
extern CGFloat const kJBChartViewUndefinedMinimumValue; // helper for undefined min/max values
|
||||
extern CGFloat const kJBChartViewUndefinedMaximumValue;
|
||||
|
||||
/**
|
||||
* At a minimum, a chart can support two states, along with animations to-and-from.
|
||||
@@ -29,6 +31,7 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
|
||||
/**
|
||||
* Header and footer views are shown above and below the chart respectively.
|
||||
* Each view will be stretched horizontally to fill width of chart.
|
||||
* Each view's bounds are clipped to support chart state animations.
|
||||
*/
|
||||
@property (nonatomic, strong) UIView *footerView;
|
||||
@property (nonatomic, strong) UIView *headerView;
|
||||
@@ -38,6 +41,19 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
|
||||
*/
|
||||
@property (nonatomic, assign) CGFloat headerPadding;
|
||||
|
||||
/**
|
||||
* The minimum and maxmimum values of the chart.
|
||||
* If no value(s) are supplied, the min and max values of the chart's data source are used.
|
||||
*
|
||||
* If value(s) are supplied, they must be >= 0, otherwise an assertion will be thrown.
|
||||
* The min/max values are clamped to the ceiling and floor of the actual min/max values of the chart's data source;
|
||||
* for example, if a maximumValue of 20 is supplied & the chart's actual max is 100, then 100 will be used.
|
||||
*
|
||||
* For min/max modifications to take effect, reloadData must be called.
|
||||
*/
|
||||
@property (nonatomic, assign) CGFloat mininumValue;
|
||||
@property (nonatomic, assign) CGFloat maximumValue;
|
||||
|
||||
/**
|
||||
* Charts can either be expanded or contracted.
|
||||
* By default, a chart should be expanded on initialization.
|
||||
@@ -50,6 +66,16 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
|
||||
*/
|
||||
- (void)reloadData;
|
||||
|
||||
/**
|
||||
* State setter.
|
||||
*
|
||||
* @param state Either collapse or expanded.
|
||||
* @param animated Whether or not the state should be animated or not.
|
||||
* @param callback Called once the animation is completed. If animated == NO, then callback is immediate.
|
||||
* @param force If current state == new state, then setting force to YES will re-configure the chart (default NO).
|
||||
*/
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback force:(BOOL)force;
|
||||
|
||||
/**
|
||||
* State setter.
|
||||
*
|
||||
|
||||
+48
-4
@@ -9,12 +9,18 @@
|
||||
#import "JBChartView.h"
|
||||
|
||||
CGFloat const kJBChartViewDefaultAnimationDuration = 0.25f;
|
||||
CGFloat const kJBChartViewUndefinedMinimumValue = -1.0f;
|
||||
CGFloat const kJBChartViewUndefinedMaximumValue = -1.0f;
|
||||
|
||||
// Color (JBChartSelectionView)
|
||||
static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
|
||||
@interface JBChartView ()
|
||||
|
||||
// Construction
|
||||
- (void)constructChartView;
|
||||
|
||||
// Validation
|
||||
- (void)validateHeaderAndFooterHeights;
|
||||
|
||||
@end
|
||||
@@ -23,12 +29,22 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
|
||||
#pragma mark - Alloc/Init
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self)
|
||||
{
|
||||
[self constructChartView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
self.clipsToBounds = YES;
|
||||
[self constructChartView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -38,6 +54,15 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
return [self initWithFrame:CGRectZero];
|
||||
}
|
||||
|
||||
#pragma mark - Construction
|
||||
|
||||
- (void)constructChartView
|
||||
{
|
||||
self.clipsToBounds = YES;
|
||||
_mininumValue = kJBChartViewUndefinedMinimumValue;
|
||||
_maximumValue = kJBChartViewUndefinedMaximumValue;
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
- (void)reloadData
|
||||
@@ -45,7 +70,7 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
// Override
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
#pragma mark - Validation
|
||||
|
||||
- (void)validateHeaderAndFooterHeights
|
||||
{
|
||||
@@ -62,6 +87,7 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
_headerView = nil;
|
||||
}
|
||||
_headerView = headerView;
|
||||
_headerView.clipsToBounds = YES;
|
||||
|
||||
[self validateHeaderAndFooterHeights];
|
||||
|
||||
@@ -77,6 +103,7 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
_footerView = nil;
|
||||
}
|
||||
_footerView = footerView;
|
||||
_footerView.clipsToBounds = YES;
|
||||
|
||||
[self validateHeaderAndFooterHeights];
|
||||
|
||||
@@ -84,9 +111,9 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback force:(BOOL)force
|
||||
{
|
||||
if (_state == state)
|
||||
if ((_state == state) && !force)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -96,6 +123,11 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
// Override
|
||||
}
|
||||
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback
|
||||
{
|
||||
[self setState:state animated:animated callback:callback force:NO];
|
||||
}
|
||||
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated
|
||||
{
|
||||
[self setState:state animated:animated callback:nil];
|
||||
@@ -106,6 +138,18 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
[self setState:state animated:NO];
|
||||
}
|
||||
|
||||
- (void)setMininumValue:(CGFloat)mininumValue
|
||||
{
|
||||
NSAssert(mininumValue >= 0, @"JBChartView // the minimumValue must be >= 0.");
|
||||
_mininumValue = mininumValue;
|
||||
}
|
||||
|
||||
- (void)setMaximumValue:(CGFloat)maximumValue
|
||||
{
|
||||
NSAssert(maximumValue >= 0, @"JBChartView // the maximumValue must be >= 0.");
|
||||
_maximumValue = maximumValue;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation JBChartVerticalSelectionView
|
||||
|
||||
Regular → Executable
+87
-4
@@ -13,11 +13,11 @@
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
/**
|
||||
* Solid round capped line.
|
||||
* Solid line.
|
||||
*/
|
||||
JBLineChartViewLineStyleSolid,
|
||||
/**
|
||||
* Dashed square capped line with a phase of 3:2 (3 points dashed, 2 points spaced).
|
||||
* Dashed line with a phase of 3:2 (3 points dashed, 2 points spaced).
|
||||
*/
|
||||
JBLineChartViewLineStyleDashed
|
||||
};
|
||||
@@ -70,7 +70,8 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
* Occurs whenever there is a touch gesture on the chart (chart must be expanded).
|
||||
* The horizontal index is the closest index to the touch point & is clamped to it's max/min value if it moves outside of the view's bounds.
|
||||
* The lineIndex remains constant until the line is unselected and will be highlighted using the (optional) selectionColorForLineAtLineIndex: protocol.
|
||||
* Futhermore, all other lines that aren't selected will be dimmed to 50% opacity throughout the duration of the touch/move.
|
||||
* Futhermore, all other lines that aren't selected will be dimmed to 20%% opacity throughout the duration of the touch/move. Any dotted line that isn't the
|
||||
* primary selection will have it's dots dimmed to hidden (to avoid transparency issues).
|
||||
*
|
||||
* @param lineChartView A line chart object informing the delegate about the new selection.
|
||||
* @param lineIndex An index number identifying the closest line in the chart to the current touch
|
||||
@@ -126,6 +127,21 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
*/
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the color of a particular dot in a line at lineIndex within the chart.
|
||||
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
|
||||
* Any value can be returned for lineIndex's that don't support dots, as it will never be called.
|
||||
*
|
||||
* Default: black color.
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).point.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return The color to be used to color a dot within a dotted line in the chart.
|
||||
*/
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the width of particular line at lineIndex within the chart.
|
||||
*
|
||||
@@ -138,6 +154,33 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
*/
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView widthForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the radius of all dots in a particular line at lineIndex within the chart.
|
||||
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
|
||||
* Any value can be returned for lineIndex's that don't support dots, as it will never be called.
|
||||
*
|
||||
* Default: line width x 3.
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return The radius of the dots within a dotted line in the chart.
|
||||
*/
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the width of the (vertical) selection view to be overlayed on the chart during touch events.
|
||||
* The property showsVerticalSelection must be YES for the width to apply. The width is clamped to the
|
||||
* maxmimum width of the chart's bounds.
|
||||
*
|
||||
* Default: 20px.
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
*
|
||||
* @return The width of the selection view used during chart selections.
|
||||
*/
|
||||
- (CGFloat)verticalSelectionWidthForLineChartView:(JBLineChartView *)lineChartView;
|
||||
|
||||
/**
|
||||
* Returns the (vertical) selection color to be overlayed on the chart during touch events.
|
||||
* The color is automically faded to transparent (vertically). The property showsVerticalSelection
|
||||
@@ -147,7 +190,7 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
*
|
||||
* @return The color to be used on chart selections.
|
||||
* @return The color of the selection view used during chart selections.
|
||||
*/
|
||||
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView;
|
||||
|
||||
@@ -164,6 +207,20 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
*/
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the selection color to be overlayed on a line within the chart during touch events.
|
||||
* The property showsLineSelection must be YES for the color to apply.
|
||||
*
|
||||
* Default: white color.
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).point.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return The color to be used to highlight a dot within a dotted line during chart selections.
|
||||
*/
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the line style of a particular line at lineIndex within the chart.
|
||||
* See JBLineChartViewLineStyle for line style descriptions.
|
||||
@@ -177,4 +234,30 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
*/
|
||||
- (JBLineChartViewLineStyle)lineChartView:(JBLineChartView *)lineChartView lineStyleForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns whether or not a line should show a dot for each point.
|
||||
* Dot size is relative to the line width and not adjustable.
|
||||
* Dot color is equal to the line color and not adjustable.
|
||||
*
|
||||
* Default: NO
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return Whether or not a line should show a dot for each chart point.
|
||||
*/
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns whether or not a line should be rendered with curved connections and rounded end caps.
|
||||
*
|
||||
* Default: NO
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return Whether or not a line should smooth it's connections and end caps.
|
||||
*/
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
@end
|
||||
|
||||
Regular → Executable
+785
-328
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,19 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "JBChartView"
|
||||
s.version = "2.0.0"
|
||||
s.version = "2.4.2"
|
||||
s.summary = "Jawbone's iOS-based charting library for both line and bar graphs."
|
||||
s.homepage = "https://github.com/Jawbone/JBChartView"
|
||||
|
||||
s.screenshot = "https://raw.github.com/Jawbone/JBChartView/master/Screenshots/main.png"
|
||||
|
||||
s.license = { :type => 'Apache', :file => 'LICENSE' }
|
||||
s.author = { "Terry Worona" => "tworona@jawbone.com" }
|
||||
s.source = {
|
||||
:git => "https://github.com/Jawbone/JBChartView.git",
|
||||
:tag => "v2.0.0"
|
||||
:tag => "v2.4.2"
|
||||
}
|
||||
|
||||
s.platform = :ios, '7.0'
|
||||
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
|
||||
s.source_files = 'Classes/**/*.{h,m}'
|
||||
s.requires_arc = true
|
||||
end
|
||||
@@ -130,16 +130,10 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
|
||||
[self.barChartView reloadData];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
[self.barChartView setState:JBChartViewStateExpanded animated:YES callback:nil];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self.barChartView setState:JBChartViewStateCollapsed];
|
||||
[self.barChartView setState:JBChartViewStateExpanded];
|
||||
}
|
||||
|
||||
#pragma mark - JBBarChartViewDelegate
|
||||
|
||||
@@ -165,16 +165,10 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
[self.lineChartView reloadData];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
[self.lineChartView setState:JBChartViewStateExpanded animated:YES];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self.lineChartView setState:JBChartViewStateCollapsed];
|
||||
[self.lineChartView setState:JBChartViewStateExpanded];
|
||||
}
|
||||
|
||||
#pragma mark - JBLineChartViewDelegate
|
||||
@@ -217,11 +211,21 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidLineColor: kJBColorLineChartDefaultDashedLineColor;
|
||||
}
|
||||
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidLineColor: kJBColorLineChartDefaultDashedLineColor;
|
||||
}
|
||||
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView widthForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return (lineIndex == JBLineChartLineSolid) ? kJBLineChartViewControllerChartSolidLineWidth: kJBLineChartViewControllerChartDashedLineWidth;
|
||||
}
|
||||
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return (lineIndex == JBLineChartLineSolid) ? 0.0: (kJBLineChartViewControllerChartDashedLineWidth * 4);
|
||||
}
|
||||
|
||||
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView
|
||||
{
|
||||
return [UIColor whiteColor];
|
||||
@@ -232,11 +236,26 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidSelectedLineColor: kJBColorLineChartDefaultDashedSelectedLineColor;
|
||||
}
|
||||
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidSelectedLineColor: kJBColorLineChartDefaultDashedSelectedLineColor;
|
||||
}
|
||||
|
||||
- (JBLineChartViewLineStyle)lineChartView:(JBLineChartView *)lineChartView lineStyleForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return (lineIndex == JBLineChartLineSolid) ? JBLineChartViewLineStyleSolid : JBLineChartViewLineStyleDashed;
|
||||
}
|
||||
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return lineIndex == JBLineChartViewLineStyleDashed;
|
||||
}
|
||||
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return lineIndex == JBLineChartViewLineStyleSolid;
|
||||
}
|
||||
|
||||
#pragma mark - Buttons
|
||||
|
||||
- (void)chartToggleButtonPressed:(id)sender
|
||||
|
||||
@@ -57,7 +57,6 @@ static UIColor *kJBBarChartFooterPolygonViewDefaultBackgroundColor = nil;
|
||||
if (self)
|
||||
{
|
||||
self.backgroundColor = kJBBarChartFooterPolygonViewDefaultBackgroundColor;
|
||||
self.clipsToBounds = NO;
|
||||
|
||||
_footerBackgroundColor = kJBBarChartFooterPolygonViewDefaultBackgroundColor;
|
||||
_padding = kJBBarChartFooterPolygonViewDefaultPadding;
|
||||
@@ -124,7 +123,6 @@ static UIColor *kJBBarChartFooterPolygonViewDefaultBackgroundColor = nil;
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
self.clipsToBounds = NO;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return self;
|
||||
|
||||
@@ -39,7 +39,6 @@ static UIColor *kJBLineChartFooterViewDefaultSeparatorColor = nil;
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
self.clipsToBounds = NO;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
_footerSeparatorColor = kJBLineChartFooterViewDefaultSeparatorColor;
|
||||
|
||||
@@ -14,6 +14,8 @@ Introducing <b>JBChartView - </b> Jawbone's iOS-based charting library for both
|
||||
- Highly customizable.
|
||||
- Expand & collapse animation support.
|
||||
|
||||
Refer to the <a href="https://github.com/Jawbone/JBChartView/blob/master/CHANGELOG.md"">changelog</a> for an overview of JBChartView's feature history.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Requires iOS 7 or later
|
||||
@@ -36,7 +38,7 @@ Simply add the following line to your <code>Podfile</code>:
|
||||
Your Podfile should look something like:
|
||||
|
||||
platform :ios, '7.0'
|
||||
pod 'JBChartView', '~> 2.0.0'
|
||||
pod 'JBChartView', '~> 2.4.2'
|
||||
|
||||
### The Old School Way
|
||||
|
||||
@@ -72,6 +74,11 @@ Secondly, you need to inform the delegate the height of each bar (automatically
|
||||
{
|
||||
return ...; // height of bar at index
|
||||
}
|
||||
|
||||
Lastly, ensure you have set the *frame* of your barChartView & call *reloadData* at least once:
|
||||
|
||||
barChartView.frame = CGRectMake( ... );
|
||||
[barChartView reloadData];
|
||||
|
||||
#### JBLineChartView
|
||||
|
||||
@@ -100,6 +107,12 @@ Secondly, you need to inform the delegate of the y-position of each point (autom
|
||||
{
|
||||
return ...; // y-position (y-axis) of point at horizontalIndex (x-axis)
|
||||
}
|
||||
|
||||
Lastly, ensure you have set the *frame* of your lineChartView & call *reloadData* at least once:
|
||||
|
||||
lineChartView.frame = CGRectMake( ... );
|
||||
[lineChartView reloadData];
|
||||
|
||||
|
||||
## Customization
|
||||
|
||||
@@ -168,17 +181,40 @@ The color, width and style of each line in the chart can be customized via the <
|
||||
return ...; // style of line in chart
|
||||
}
|
||||
|
||||
Furthermore, the color of the selection bar and line can be customized via the <i>optional</i> protocols:
|
||||
Furthermore, the color and width of the selection view along with the color of the selected line can be customized via the <i>optional</i> protocols:
|
||||
|
||||
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView
|
||||
{
|
||||
return ...; // color of selection view
|
||||
}
|
||||
|
||||
- (CGFloat)verticalSelectionWidthForLineChartView:(JBLineChartView *)lineChartView
|
||||
{
|
||||
return ...; // width of selection view
|
||||
}
|
||||
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return ...; // color of selected line
|
||||
}
|
||||
|
||||
By default, each line will not show dots for each point. To enable this on a per-line basis:
|
||||
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
To customize the size of each dot (default 3x the line width), implement:
|
||||
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
To customize the color of each dot during selection and non-selection events (default is white and black respectively), implement:
|
||||
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
As well, by default, each line will have squared off end caps and connection points. To enable rounded connections and end caps:
|
||||
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
Lastly, a line chart's selection events are delegated back via:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user