Compare commits

..

8 Commits

Author SHA1 Message Date
terryworona 9292655de8 messing around with loading states 2016-08-28 17:59:02 -07:00
terryworona 5468952b53 update change log and pod spec 2016-06-22 12:57:40 -07:00
terryworona af508bb50c Fixed setState crasher with cached bar heights 2016-06-22 12:52:18 -07:00
terryworona 988c8c9ab9 update pod spec and changelog 2016-06-22 11:44:14 -07:00
terryworona 7944c03962 Merge pull request #209 from loumoore/master
Handle NaN line slope in line chart selection code.
2016-06-21 17:33:45 -07:00
Lou Moore e28a0113f8 PR feedback 2016-06-21 17:31:32 -07:00
Lou Moore 40ae91de47 Handle NaN line slope in line chart selection code. 2016-06-21 17:19:10 -07:00
terryworona 251b6e888f updated pod spec and change log 2016-05-30 19:35:38 -07:00
7 changed files with 141 additions and 14 deletions
+21
View File
@@ -1,5 +1,26 @@
# Change Log
## [v3.0.12](https://github.com/Jawbone/JBChartView/tree/v3.0.12) (2016-06-22)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.11...v3.0.12)
## [v3.0.11](https://github.com/Jawbone/JBChartView/tree/v3.0.11) (2016-06-22)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.10...v3.0.11)
**Fixed bugs:**
- barChartView:barViewAtIndex: not called when reloading bar chart animated [\#207](https://github.com/Jawbone/JBChartView/issues/207)
**Closed issues:**
- Not able to change the color of linechart with custom color [\#208](https://github.com/Jawbone/JBChartView/issues/208)
**Merged pull requests:**
- Handle NaN line slope in line chart selection code. [\#209](https://github.com/Jawbone/JBChartView/pull/209) ([loumoore](https://github.com/loumoore))
## [v3.0.10](https://github.com/Jawbone/JBChartView/tree/v3.0.10) (2016-05-31)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.9...v3.0.10)
## [v3.0.9](https://github.com/Jawbone/JBChartView/tree/v3.0.9) (2016-04-28)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.8...v3.0.9)
+1 -1
View File
@@ -606,7 +606,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
dispatch_block_t callbackCopy = [callback copy];
if ([self.barViews count] > 0)
if ([self.barViews count] > 0 && [self.cachedBarViewHeights count] == [self.barViews count])
{
if (animated)
{
+9
View File
@@ -69,6 +69,15 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
@property (nonatomic, weak) id<JBChartViewDataSource> dataSource;
@property (nonatomic, weak) id<JBChartViewDelegate> delegate;
/*
* Since loading is such a common UIView requirement,
* setting to YES will snapshot the chart, blur it, and display a loading indicator.
*/
@property (nonatomic, assign) BOOL loading;
- (void)setLoading:(BOOL)loading animated:(BOOL)animated callback:(void (^)())callback;
- (void)setLoading:(BOOL)loading animated:(BOOL)animated;
/**
* Header and footer views are shown above and below the chart respectively.
* Each view will be stretched horizontally to fill width of chart.
+105
View File
@@ -16,6 +16,8 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
@interface JBChartView ()
@property (nonatomic, strong) UIImageView *loadingImageView;
@property (nonatomic, assign) BOOL hasMaximumValue;
@property (nonatomic, assign) BOOL hasMinimumValue;
@@ -77,8 +79,111 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
NSAssert((self.headerView.bounds.size.height + self.footerView.bounds.size.height) <= self.bounds.size.height, @"JBChartView // the combined height of the footer and header can not be greater than the total height of the chart.");
}
#pragma mark - Getters
+ (UIImage *)imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
#pragma mark - Setters
- (void)setLoading:(BOOL)loading animated:(BOOL)animated callback:(void (^)())callback
{
if (_loading == loading)
{
return;
}
_loading = loading;
if (loading) // show
{
UIImage *snapshotImage = [JBChartView imageWithView:self];
self.loadingImageView = [[UIImageView alloc] initWithImage:snapshotImage];
self.loadingImageView.frame = self.bounds;
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
effectView.frame = self.loadingImageView.frame;
[self.loadingImageView addSubview:effectView];
UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicatorView startAnimating];
activityIndicatorView.frame = CGRectMake(ceil(self.loadingImageView.frame.size.width * 0.5) - ceil(activityIndicatorView.frame.size.width * 0.5), ceil(self.loadingImageView.frame.size.height * 0.5) - ceil(activityIndicatorView.frame.size.height * 0.5), activityIndicatorView.frame.size.width, activityIndicatorView.frame.size.height);
[self.loadingImageView addSubview:activityIndicatorView];
if (animated)
{
self.loadingImageView.alpha = 0.0;
[self addSubview:self.loadingImageView];
[UIView animateWithDuration:0.25 animations:^{
self.loadingImageView.alpha = 1.0;
} completion:^(BOOL finished) {
if (callback)
{
callback();
}
}];
}
else
{
[self addSubview:self.loadingImageView];
if (callback)
{
callback();
}
}
}
else // hide
{
if (self.loadingImageView != nil)
{
if (animated)
{
[UIView animateWithDuration:0.25 animations:^{
self.loadingImageView.alpha = 0.0;
} completion:^(BOOL finished) {
[self.loadingImageView removeFromSuperview];
if (callback)
{
callback();
}
}];
}
else
{
[self.loadingImageView removeFromSuperview];
if (callback)
{
callback();
}
}
}
else
{
if (callback)
{
callback();
}
}
}
}
- (void)setLoading:(BOOL)loading animated:(BOOL)animated
{
[self setLoading:loading animated:animated callback:nil];
}
- (void)setLoading:(BOOL)loading
{
[self setLoading:loading animated:NO];
}
- (void)setHeaderView:(UIView *)headerView
{
if (_headerView)
+2 -2
View File
@@ -1035,8 +1035,8 @@ static NSInteger const kJBLineChartUnselectedLineIndex = -1;
// Touch point
CGPoint normalizedTouchPoint = CGPointMake(point.x, self.linesView.bounds.size.height - point.y);
// Slope
CGFloat lineSlope = (CGFloat)(rightPoint.y - leftPoint.y) / (CGFloat)(rightPoint.x - leftPoint.x);
// Slope - set to zero if x coordinates are the same and would result in a NaN value
CGFloat lineSlope = rightPoint.x != leftPoint.x ? (CGFloat)(rightPoint.y - leftPoint.y) / (CGFloat)(rightPoint.x - leftPoint.x) : 0.0f;
// Insersection point
CGPoint interesectionPoint = CGPointMake(normalizedTouchPoint.x, (lineSlope * (normalizedTouchPoint.x - leftPoint.x)) + leftPoint.y);
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "JBChartView"
s.version = "3.0.9"
s.version = "3.0.12"
s.summary = "Jawbone's iOS-based charting library for both line and bar graphs."
s.homepage = "https://github.com/Jawbone/JBChartView"
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.author = { "Terry Worona" => "tworona@jawbone.com" }
s.source = {
:git => "https://github.com/Jawbone/JBChartView.git",
:tag => "v3.0.9"
:tag => "v3.0.12"
}
s.platform = :ios, '6.0'
@@ -305,15 +305,7 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
- (void)chartToggleButtonPressed:(id)sender
{
UIView *buttonImageView = [self.navigationItem.rightBarButtonItem valueForKey:kJBLineChartViewControllerNavButtonViewKey];
buttonImageView.userInteractionEnabled = NO;
CGAffineTransform transform = self.lineChartView.state == JBChartViewStateExpanded ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformMakeRotation(0);
buttonImageView.transform = transform;
[self.lineChartView setState:self.lineChartView.state == JBChartViewStateExpanded ? JBChartViewStateCollapsed : JBChartViewStateExpanded animated:YES callback:^{
buttonImageView.userInteractionEnabled = YES;
}];
[self.chartView setLoading:!self.chartView.loading animated:YES];
}
#pragma mark - Overrides