From 3a14c1db2a3a97d490baed23d843c5ea7976a137 Mon Sep 17 00:00:00 2001 From: Jan Lubeck Date: Mon, 13 Nov 2017 11:40:13 -0500 Subject: [PATCH 1/3] Fixes "This block declaration is not a prototype" on Xcode 9 --- Classes/Base/JBChartView.h | 4 ++-- Classes/Base/JBChartView.m | 4 ++-- Classes/Line/Views/JBLineChartDotsView.h | 2 +- Classes/Line/Views/JBLineChartDotsView.m | 2 +- Classes/Line/Views/JBLineChartLinesView.h | 4 ++-- Classes/Line/Views/JBLineChartLinesView.m | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Classes/Base/JBChartView.h b/Classes/Base/JBChartView.h index 6fa941071..b20105e48 100644 --- a/Classes/Base/JBChartView.h +++ b/Classes/Base/JBChartView.h @@ -132,7 +132,7 @@ typedef NS_ENUM(NSInteger, JBChartViewState){ * @param force If current state == new state, then setting force to YES will re-configure the chart (default NO). * @param callback Called once the animation is completed. If animated == NO, then callback is immediate. */ -- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)())callback; +- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)(void))callback; /** * State setter. @@ -141,7 +141,7 @@ typedef NS_ENUM(NSInteger, JBChartViewState){ * @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. */ -- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback; +- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)(void))callback; /** * State setter. diff --git a/Classes/Base/JBChartView.m b/Classes/Base/JBChartView.m index 2515475bd..a86118568 100644 --- a/Classes/Base/JBChartView.m +++ b/Classes/Base/JBChartView.m @@ -111,7 +111,7 @@ - (void)setFooterView:(UIView *)footerView [self reloadData]; } -- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)())callback +- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)(void))callback { if ((_state == state) && !force) { @@ -123,7 +123,7 @@ - (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)for // Override } -- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback +- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)(void))callback { [self setState:state animated:animated force:NO callback:callback]; } diff --git a/Classes/Line/Views/JBLineChartDotsView.h b/Classes/Line/Views/JBLineChartDotsView.h index b2321843f..b31566a1a 100644 --- a/Classes/Line/Views/JBLineChartDotsView.h +++ b/Classes/Line/Views/JBLineChartDotsView.h @@ -21,7 +21,7 @@ extern NSInteger const kJBLineChartDotsViewUnselectedLineIndex; @property (nonatomic, strong) NSDictionary *dotViewsDict; // Data -- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)())callback; +- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)(void))callback; - (void)reloadDataAnimated:(BOOL)animated; - (void)reloadData; diff --git a/Classes/Line/Views/JBLineChartDotsView.m b/Classes/Line/Views/JBLineChartDotsView.m index 2d4dc2ef1..17a12376b 100644 --- a/Classes/Line/Views/JBLineChartDotsView.m +++ b/Classes/Line/Views/JBLineChartDotsView.m @@ -39,7 +39,7 @@ - (id)initWithFrame:(CGRect)frame #pragma mark - Data -- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)())callback +- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)(void))callback { NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesForLineChartDotsView:)], @"JBLineChartDotsView // dataSource must implement - (NSArray *)lineChartLinesForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView"); NSArray *lineChartLines = [self.dataSource lineChartLinesForLineChartDotsView:self]; diff --git a/Classes/Line/Views/JBLineChartLinesView.h b/Classes/Line/Views/JBLineChartLinesView.h index b4f083169..ac5af1d82 100644 --- a/Classes/Line/Views/JBLineChartLinesView.h +++ b/Classes/Line/Views/JBLineChartLinesView.h @@ -20,7 +20,7 @@ extern NSInteger const kJBLineChartLinesViewUnselectedLineIndex; @property (nonatomic, assign) NSInteger selectedLineIndex; // -1 to unselect // Data -- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)())callback; +- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)(void))callback; - (void)reloadDataAnimated:(BOOL)animated; - (void)reloadData; @@ -28,7 +28,7 @@ extern NSInteger const kJBLineChartLinesViewUnselectedLineIndex; - (void)setSelectedLineIndex:(NSInteger)selectedLineIndex animated:(BOOL)animated; // Callback helpers -- (void)fireCallback:(void (^)())callback; +- (void)fireCallback:(void (^)(void))callback; @end diff --git a/Classes/Line/Views/JBLineChartLinesView.m b/Classes/Line/Views/JBLineChartLinesView.m index ea335d5cb..032a19884 100644 --- a/Classes/Line/Views/JBLineChartLinesView.m +++ b/Classes/Line/Views/JBLineChartLinesView.m @@ -195,7 +195,7 @@ - (void)drawRect:(CGRect)rect #pragma mark - Data -- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)())callback +- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)(void))callback { NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesForLineChartLinesView:)], @"JBLineChartLinesView // dataSource must implement - (NSArray *)lineChartLinesForLineChartLinesView:(JBLineChartLinesView *)lineChartLinesView"); NSArray *chartData = [self.dataSource lineChartLinesForLineChartLinesView:self]; @@ -584,7 +584,7 @@ - (CABasicAnimation *)basicPathAnimationFromBezierPath:(UIBezierPath *)fromBezie #pragma mark - Callback Helpers -- (void)fireCallback:(void (^)())callback +- (void)fireCallback:(void (^)(void))callback { dispatch_block_t callbackCopy = [callback copy]; From 2b5bb2acdaa7272fe8ebd91174aa9027e5dc7bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20L=C3=BCbeck?= Date: Mon, 6 Aug 2018 17:57:18 -0400 Subject: [PATCH 2/3] Support for negative values --- Classes/Base/JBChartView.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/Classes/Base/JBChartView.m b/Classes/Base/JBChartView.m index a86118568..c764b957c 100644 --- a/Classes/Base/JBChartView.m +++ b/Classes/Base/JBChartView.m @@ -140,14 +140,12 @@ - (void)setState:(JBChartViewState)state - (void)setMinimumValue:(CGFloat)minimumValue { - NSAssert(minimumValue >= 0, @"JBChartView // the minimumValue must be >= 0."); _minimumValue = minimumValue; _hasMinimumValue = YES; } - (void)setMaximumValue:(CGFloat)maximumValue { - NSAssert(maximumValue >= 0, @"JBChartView // the maximumValue must be >= 0."); _maximumValue = maximumValue; _hasMaximumValue = YES; } From f743f4f734800f5e260fa3441173bfba06a81562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20L=C3=BCbeck?= Date: Mon, 6 Aug 2018 17:57:44 -0400 Subject: [PATCH 3/3] Support for negative values --- Classes/Line/JBLineChartView.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/Classes/Line/JBLineChartView.m b/Classes/Line/JBLineChartView.m index 23ac7e18e..f2698d61f 100755 --- a/Classes/Line/JBLineChartView.m +++ b/Classes/Line/JBLineChartView.m @@ -208,7 +208,6 @@ - (void)reloadDataAnimated:(BOOL)animated { NSAssert([self.delegate respondsToSelector:@selector(lineChartView:verticalValueForHorizontalIndex:atLineIndex:)], @"JBLineChartView // delegate must implement - (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex"); CGFloat rawHeight = [self.delegate lineChartView:self verticalValueForHorizontalIndex:horizontalIndex atLineIndex:lineIndex]; - NSAssert(isnan(rawHeight) || (rawHeight >= 0), @"JBLineChartView // delegate function - (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex must return a CGFloat >= 0 OR NAN"); JBLineChartPoint *chartPointModel = [[JBLineChartPoint alloc] init]; { @@ -863,7 +862,6 @@ - (CGFloat)cachedMinHeight { NSAssert([self.delegate respondsToSelector:@selector(lineChartView:verticalValueForHorizontalIndex:atLineIndex:)], @"JBLineChartView // delegate must implement - (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex"); CGFloat height = [self.delegate lineChartView:self verticalValueForHorizontalIndex:horizontalIndex atLineIndex:lineIndex]; - NSAssert(isnan(height) || (height >= 0), @"JBLineChartView // delegate function - (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex must return a CGFloat >= 0 OR NAN"); if (!isnan(height) && height < minHeight) { minHeight = height; @@ -890,7 +888,6 @@ - (CGFloat)cachedMaxHeight { NSAssert([self.delegate respondsToSelector:@selector(lineChartView:verticalValueForHorizontalIndex:atLineIndex:)], @"JBLineChartView // delegate must implement - (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex"); CGFloat height = [self.delegate lineChartView:self verticalValueForHorizontalIndex:horizontalIndex atLineIndex:lineIndex]; - NSAssert(isnan(height) || (height >= 0), @"JBLineChartView // delegate function - (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex must return a CGFloat >= 0 OR NAN"); if (!isnan(height) && height > maxHeight) { maxHeight = height;