Compare commits
11 Commits
v3.0.9
...
pinch-zoom
| Author | SHA1 | Date | |
|---|---|---|---|
| e74bef481b | |||
| 212e14e1e2 | |||
| 5468952b53 | |||
| af508bb50c | |||
| 988c8c9ab9 | |||
| 7944c03962 | |||
| e28a0113f8 | |||
| 40ae91de47 | |||
| 251b6e888f | |||
| c2558f9975 | |||
| 2d1450340b |
@@ -1,5 +1,41 @@
|
||||
# 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)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- ability to set line chart view padding [\#205](https://github.com/Jawbone/JBChartView/issues/205)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- old gradient fill shows if chart is scrolled offscreen [\#204](https://github.com/Jawbone/JBChartView/issues/204)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- example of using gradient for fills [\#202](https://github.com/Jawbone/JBChartView/issues/202)
|
||||
|
||||
## [v3.0.8](https://github.com/Jawbone/JBChartView/tree/v3.0.8) (2016-02-29)
|
||||
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.7...v3.0.8)
|
||||
|
||||
|
||||
@@ -149,6 +149,28 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
* Final block to refresh state and turn off reloading bit
|
||||
*/
|
||||
dispatch_block_t completionBlock = ^{
|
||||
|
||||
if (animated)
|
||||
{
|
||||
[self.chartData enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger index, BOOL * _Nonnull stop) {
|
||||
// Grab old bar
|
||||
UIView *oldBarView = [self.barViews objectAtIndex:index];
|
||||
|
||||
// Update bar instance
|
||||
UIView *barView = [self createBarViewForIndex:index];
|
||||
barView.frame = oldBarView.frame;
|
||||
|
||||
// Swap subviews
|
||||
[oldBarView removeFromSuperview];
|
||||
[self insertBarView:barView];
|
||||
|
||||
// Update bar colection
|
||||
NSMutableArray *mutableBarViews = [NSMutableArray arrayWithArray:self.barViews];
|
||||
[mutableBarViews replaceObjectAtIndex:index withObject:barView];
|
||||
self.barViews = [NSArray arrayWithArray:mutableBarViews];
|
||||
}];
|
||||
}
|
||||
|
||||
self.reloading = NO;
|
||||
[self setState:self.state animated:NO force:YES callback:nil];
|
||||
};
|
||||
@@ -584,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)
|
||||
{
|
||||
|
||||
@@ -14,8 +14,16 @@ CGFloat const kJBChartViewDefaultAnimationDuration = 0.25f;
|
||||
// Color (JBChartSelectionView)
|
||||
static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
|
||||
@interface JAPinchZoomView : UIView <UIScrollViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) UIScrollView *scrollView;
|
||||
@property (nonatomic, strong) UIImageView *pinchZoomImageView;
|
||||
|
||||
@end
|
||||
|
||||
@interface JBChartView ()
|
||||
|
||||
@property (nonatomic, strong) JAPinchZoomView *pinchZoomView;
|
||||
@property (nonatomic, assign) BOOL hasMaximumValue;
|
||||
@property (nonatomic, assign) BOOL hasMinimumValue;
|
||||
|
||||
@@ -61,6 +69,36 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
- (void)constructChartView
|
||||
{
|
||||
self.clipsToBounds = YES;
|
||||
|
||||
UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureRecognized:)];
|
||||
pinchGestureRecognizer.cancelsTouchesInView = NO;
|
||||
[self addGestureRecognizer:pinchGestureRecognizer];
|
||||
}
|
||||
|
||||
#pragma mark - Gestures
|
||||
|
||||
- (void)pinchGestureRecognized:(UIPinchGestureRecognizer *)pinchGestureRecognizer
|
||||
{
|
||||
if (pinchGestureRecognizer.state == UIGestureRecognizerStateBegan)
|
||||
{
|
||||
for (UIView *subview in self.subviews)
|
||||
{
|
||||
//subview.hidden = YES;
|
||||
}
|
||||
|
||||
self.pinchZoomView = [[JAPinchZoomView alloc] init];
|
||||
self.pinchZoomView.pinchZoomImageView.image = [JBChartView imageWithView:self];
|
||||
self.pinchZoomView.frame = self.bounds;
|
||||
[self addSubview:self.pinchZoomView];
|
||||
}
|
||||
else if (pinchGestureRecognizer.state == UIGestureRecognizerStateEnded)
|
||||
{
|
||||
for (UIView *subview in self.subviews)
|
||||
{
|
||||
// subview.hidden = NO;
|
||||
}
|
||||
//[self.pinchZoomView removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
@@ -77,6 +115,17 @@ 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)setHeaderView:(UIView *)headerView
|
||||
@@ -233,3 +282,44 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation JAPinchZoomView
|
||||
|
||||
#pragma mark - Alloc/Init
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_scrollView = [[UIScrollView alloc] init];
|
||||
_scrollView.delegate = self;
|
||||
_scrollView.minimumZoomScale = 1.0;
|
||||
_scrollView.maximumZoomScale = 6.0;
|
||||
[self addSubview:_scrollView];
|
||||
|
||||
_pinchZoomImageView = [[UIImageView alloc] init];
|
||||
[_scrollView addSubview:_pinchZoomImageView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
self.scrollView.frame = self.bounds;
|
||||
self.pinchZoomImageView.frame = self.scrollView.bounds;
|
||||
}
|
||||
|
||||
#pragma mark - UIScrollViewDelegate
|
||||
|
||||
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
|
||||
{
|
||||
return self.pinchZoomImageView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "JBChartView"
|
||||
s.version = "3.0.8"
|
||||
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.8"
|
||||
:tag => "v3.0.12"
|
||||
}
|
||||
|
||||
s.platform = :ios, '6.0'
|
||||
|
||||
Reference in New Issue
Block a user