Compare commits

...

60 Commits

Author SHA1 Message Date
Terry Worona 87b62ad2b1 updated change log, pod spec, read me 2014-04-28 12:06:03 -07:00
Terry Worona 9c0d788418 More style updates 2014-04-28 12:00:59 -07:00
Terry Worona de009f0236 PR #39 cleanup 2014-04-28 11:25:45 -07:00
ktran03 d46e4fe14d changed compare condition to using slope instead of vertical diff 2014-04-26 18:32:40 -04:00
ktran03 236336fdf3 added check for y-value difference if exceeds threshold 2014-04-25 15:14:16 -04:00
ktran03 9b60a1d662 Expose smooth option through delegate, fix diffs 2014-04-24 14:35:54 -04:00
ktran03 3700b4e2e2 smooth curve using bezierpath 2014-04-19 20:15:53 -04:00
Terry Worona 8c03033a1c Added screenshot to pod spec 2014-04-18 10:14:42 -07:00
Terry Worona bb084b1b89 Fixes issue #34 2014-04-17 18:32:58 -07:00
Terry Worona 1c7c8b2e52 Updated read me, pod spec etc for new version 2014-04-14 10:36:07 -07:00
Terry Worona 79a57d98e3 Clamp selection width to width of chart 2014-04-14 10:32:50 -07:00
Terry Worona 20d6b6081b Fixed comment 2014-04-14 10:30:24 -07:00
terryworona 20bbbdcc86 Merge pull request #37 from veducm/master
Added delegate method to configure the width of the vertical selection bar in a line chart.
2014-04-14 10:27:51 -07:00
Edu Caselles 51ac8a1d63 Added delegate method to configure the width of the vertical selection bar in a line chart. 2014-04-14 01:35:20 +02:00
Terry Worona 68d04a2cdb Fixes issue #36 2014-04-12 09:11:41 -07:00
Terry Worona b7734ef189 Updated for new version 2014-04-11 15:02:46 -07:00
Terry Worona f6d2fe8b62 Fixed issue #33 2014-04-11 15:00:33 -07:00
Terry Worona 5c9679f448 updated read me, etc for new version 2014-04-10 16:18:52 -07:00
Terry Worona 037225a386 Fixed issue #30 2014-04-10 16:15:28 -07:00
terryworona 0fe979bd22 Merge pull request #30 from gumbypp/master
JBChartView: needs initWithCoder initializer for inflation from a xib
2014-04-10 16:13:34 -07:00
Dale Low 31b64ed7e4 JBChartView: needs initWithCoder initializer for inflation from a xib 2014-04-10 16:00:27 -07:00
Terry Worona c30398c3ea Updated readme 2014-04-10 13:23:26 -07:00
Terry Worona bc08322a3a Updated version 2014-04-10 13:13:38 -07:00
Terry Worona 213973f4ed Fixing line chart padding calculations for custom dot radius 2014-04-10 11:20:16 -07:00
Terry Worona 28d40bcb31 Added dot radius callbacks for line charts 2014-04-10 10:58:47 -07:00
Terry Worona d4df0184a2 Updated change log, pod spec and read me 2014-04-03 14:49:36 -07:00
Terry Worona 4f313aab80 Added state force setters 2014-04-03 14:48:01 -07:00
Terry Worona b6262462c5 Updated pod spec change log and read me 2014-04-02 11:49:52 -07:00
Terry Worona 1080089753 Added dynamic padding to line chart view 2014-04-02 11:46:42 -07:00
Terry Worona 0afba01a9a Updated read me and pod spec 2014-04-02 10:26:59 -07:00
Terry Worona 63b47667ec Fixed min and max value properties 2014-04-02 09:08:12 -07:00
Terry Worona 4d6baf066f cleaned up cached constants 2014-04-02 08:50:43 -07:00
Terry Worona 359ef7d0ea Updated read me, change log and podspec 2014-03-30 21:50:00 -07:00
Terry Worona 7b1e6475f2 Clamp min and value values if supplied 2014-03-30 21:47:00 -07:00
Terry Worona 2b8853780c added optional min and max value properties to JBChartView 2014-03-30 21:27:00 -07:00
Terry Worona 0754e2e5d2 min height patches 2014-03-29 19:20:15 -07:00
Terry Worona 52b722013e updated change log 2014-03-27 16:05:00 -07:00
Terry Worona 4ef9b6442e Changelog updates 2014-03-27 14:21:15 -07:00
Terry Worona 177e076807 Readme update 2014-03-27 14:11:12 -07:00
Terry Worona 21969d759d changelog styling 2014-03-27 14:08:28 -07:00
Terry Worona 4fd6f1cb63 Added change log 2014-03-27 14:06:32 -07:00
Terry Worona 804ce2ca67 Updated line chart header comments 2014-03-27 13:02:07 -07:00
Terry Worona 485cfb9631 Fixed dot selections 2014-03-27 12:54:12 -07:00
Terry Worona 4640dede3a updated pod spec 2014-03-26 15:14:46 -07:00
Terry Worona 1b90c6e16f Updated read me 2014-03-26 15:13:53 -07:00
Terry Worona 15b53aa68e added line smooth bools 2014-03-26 15:05:37 -07:00
Terry Worona 0e277dc347 more dot selection cleanup 2014-03-26 14:12:05 -07:00
Terry Worona 6de42998c0 selection cleanups 2014-03-26 14:09:38 -07:00
Terry Worona a1e4be3a5d Dot selections 2014-03-26 14:01:29 -07:00
Terry Worona acaf6fb4dc moved dot function to datasource for line graphs 2014-03-26 12:49:35 -07:00
Terry Worona 5894610278 finished new line chart animations 2014-03-26 11:55:58 -07:00
Terry Worona e605e60f28 Line chart animation cleanup 2014-03-26 11:34:24 -07:00
Terry Worona 33b3c9518f Simplifying line chart animations 2014-03-26 10:40:44 -07:00
Terry Worona aec3d31e17 much work on dot views for lines 2014-03-25 16:56:46 -07:00
Terry Worona c99a0429b4 Implementation cleanup 2014-03-25 16:08:28 -07:00
Terry Worona f9fc90244f created custom line dot views 2014-03-25 16:07:38 -07:00
Terry Worona 6b0198f732 Created dot view class to get perfect circles 2014-03-25 15:59:47 -07:00
Terry Worona f0e52b42d7 More class naming convention changes 2014-03-25 15:47:26 -07:00
Terry Worona 381850ada4 Updated view names 2014-03-25 15:40:00 -07:00
Terry Worona 8b22d5fadd Started dot line implementation 2014-03-25 15:35:10 -07:00
12 changed files with 1184 additions and 377 deletions
+106
View File
@@ -0,0 +1,106 @@
# Changelog
## <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.
+74 -20
View File
@@ -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:
@@ -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
+26
View File
@@ -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
View File
@@ -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
+4 -2
View File
@@ -1,14 +1,16 @@
Pod::Spec.new do |s|
s.name = "JBChartView"
s.version = "2.0.1"
s.version = "2.4.0"
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.1"
:tag => "v2.4.0"
}
s.platform = :ios, '7.0'
Regular → Executable
+87 -4
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
@@ -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;
+27 -2
View File
@@ -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.1'
pod 'JBChartView', '~> 2.4.0'
### The Old School Way
@@ -179,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: