Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52c8d632b7 | |||
| 59eebf6015 | |||
| 036c01dc03 | |||
| 063079f171 | |||
| dc56268f29 | |||
| f56b539fe4 | |||
| e4b0820418 | |||
| d30d5b9c96 | |||
| 8db9d7baaf | |||
| d49515c97e | |||
| 7dfcd44d8c | |||
| 4e511f7164 | |||
| cd2c79ffa7 |
@@ -1,5 +1,25 @@
|
||||
# Change Log
|
||||
|
||||
## [v3.0.5](https://github.com/Jawbone/JBChartView/tree/v3.0.5) (2016-01-20)
|
||||
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.4...v3.0.5)
|
||||
|
||||
## [v3.0.4](https://github.com/Jawbone/JBChartView/tree/v3.0.4) (2016-01-20)
|
||||
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.3...v3.0.4)
|
||||
|
||||
## [v3.0.3](https://github.com/Jawbone/JBChartView/tree/v3.0.3) (2016-01-20)
|
||||
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.2...v3.0.3)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Dot alpha doesn't return after unselection [\#197](https://github.com/Jawbone/JBChartView/issues/197)
|
||||
|
||||
## [v3.0.2](https://github.com/Jawbone/JBChartView/tree/v3.0.2) (2016-01-19)
|
||||
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.1...v3.0.2)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Make sure to import dependent framework header explicitly [\#196](https://github.com/Jawbone/JBChartView/pull/196) ([yasuoza](https://github.com/yasuoza))
|
||||
|
||||
## [v3.0.1](https://github.com/Jawbone/JBChartView/tree/v3.0.1) (2016-01-16)
|
||||
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v3.0.0...v3.0.1)
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
#import "JBGradientBarView.h"
|
||||
|
||||
// Numerics
|
||||
CGFloat const kJBBarChartViewBarBasePaddingMutliplier = 50.0f;
|
||||
CGFloat const kJBBarChartViewUndefinedCachedHeight = -1.0f;
|
||||
CGFloat const kJBBarChartViewStateAnimationDuration = 0.05f;
|
||||
CGFloat const kJBBarChartViewReloadDataAnimationDuration = 0.15f;
|
||||
CGFloat const kJBBarChartViewStatePopOffset = 10.0f;
|
||||
NSInteger const kJBBarChartViewUndefinedBarIndex = -1;
|
||||
static CGFloat const kJBBarChartViewBarBasePaddingMutliplier = 50.0f;
|
||||
static CGFloat const kJBBarChartViewUndefinedCachedHeight = -1.0f;
|
||||
static CGFloat const kJBBarChartViewStateAnimationDuration = 0.05f;
|
||||
static CGFloat const kJBBarChartViewReloadDataAnimationDuration = 0.15f;
|
||||
static CGFloat const kJBBarChartViewStatePopOffset = 10.0f;
|
||||
static NSInteger const kJBBarChartViewUndefinedBarIndex = -1;
|
||||
|
||||
// Colors (JBChartView)
|
||||
static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
@@ -383,7 +383,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
preAddBarViewsBlock();
|
||||
[UIView animateWithDuration:kJBBarChartViewReloadDataAnimationDuration delay:0 options:UIViewAnimationOptionTransitionNone animations:^{
|
||||
postAddBarViewsBlock();
|
||||
} completion:^(BOOL finished) {
|
||||
} completion:^(BOOL finished2) {
|
||||
refreshedCachedBarViewHeightsBlock();
|
||||
completionBlock();
|
||||
}];
|
||||
@@ -402,7 +402,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
postRemoveBarViewsBlock();
|
||||
[UIView animateWithDuration:kJBBarChartViewReloadDataAnimationDuration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
|
||||
updateExistingBarViewsBlock();
|
||||
} completion:^(BOOL finished) {
|
||||
} completion:^(BOOL finished2) {
|
||||
refreshedCachedBarViewHeightsBlock();
|
||||
completionBlock();
|
||||
}];
|
||||
@@ -753,7 +753,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
if (gradientLayer != nil)
|
||||
{
|
||||
barView = [[JBGradientBarView alloc] init];
|
||||
((JBGradientBarView *)barView).delegate = self;
|
||||
((JBGradientBarView *)barView).dataSource = self;
|
||||
((JBGradientBarView *)barView).gradientLayer = gradientLayer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
@interface JBGradientBarView: UIView
|
||||
|
||||
@property (nonatomic, weak) id<JBGradientBarViewDataSource> delegate;
|
||||
@property (nonatomic, weak) id<JBGradientBarViewDataSource> dataSource;
|
||||
@property (nonatomic, strong) CAGradientLayer *gradientLayer;
|
||||
|
||||
@end
|
||||
|
||||
@@ -66,9 +66,9 @@
|
||||
{
|
||||
[super setFrame:frame];
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(chartViewBoundsForGradientBarView:)])
|
||||
if ([self.dataSource respondsToSelector:@selector(chartViewBoundsForGradientBarView:)])
|
||||
{
|
||||
_gradientLayer.frame = [self.delegate chartViewBoundsForGradientBarView:self]; // gradient is as large as the chart
|
||||
_gradientLayer.frame = [self.dataSource chartViewBoundsForGradientBarView:self]; // gradient is as large as the chart
|
||||
_gradientLayer.frame = CGRectOffset(_gradientLayer.frame, -CGRectGetMinX(frame), 0);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -104,6 +104,19 @@ typedef NS_ENUM(NSInteger, JBLineChartViewColorStyle) {
|
||||
*/
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the opacity value to be used for dimming the dots during selection events.
|
||||
* This value is applied to all dots within a line anytime it's not selected (but another line is).
|
||||
*
|
||||
* Default: 0.0.
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return A value between 0.0 and 1.0 (will be clamped accordingly).
|
||||
*/
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dimmedSelectionDotOpacityAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns a (custom) UIView instance representing a dot (x,y point) within the chart.
|
||||
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
|
||||
|
||||
@@ -33,18 +33,19 @@ static UIColor *kJBLineChartViewDefaultFillGradientStartColor = nil;
|
||||
static UIColor *kJBLineChartViewDefaultFillGradientEndColor = nil;
|
||||
|
||||
// Numerics
|
||||
CGFloat const kJBLineChartViewDefaultVerticalSelectionViewWidth = 20.0f;
|
||||
CGFloat const kJBLineChartViewUndefinedCachedHeight = -1.0f;
|
||||
CGFloat const kJBLineChartViewStateAnimationDuration = 0.25f;
|
||||
CGFloat const kJBLineChartViewStateAnimationDelay = 0.05f;
|
||||
CGFloat const kJBLineChartViewStateBounceOffset = 15.0f;
|
||||
CGFloat const kJBLineChartViewDefaultStartPoint = 0.0;
|
||||
CGFloat const kJBLineChartViewDefaultEndPoint = 1.0;
|
||||
CGFloat const kJBLineChartViewReloadAnimationDuration = 0.1;
|
||||
CGFloat const kJBLineChartViewDefaultDimmedSelectionOpacity = 0.20f;
|
||||
CGFloat const kJBLineChartViewDefaultStrokeWidth = 5.0f;
|
||||
NSInteger const kJBLineChartViewDefaultDotRadiusFactor = 3; // 3x size of line width
|
||||
NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
static CGFloat const kJBLineChartViewDefaultVerticalSelectionViewWidth = 20.0f;
|
||||
static CGFloat const kJBLineChartViewUndefinedCachedHeight = -1.0f;
|
||||
static CGFloat const kJBLineChartViewStateAnimationDuration = 0.25f;
|
||||
static CGFloat const kJBLineChartViewStateAnimationDelay = 0.05f;
|
||||
static CGFloat const kJBLineChartViewStateBounceOffset = 15.0f;
|
||||
static CGFloat const kJBLineChartViewDefaultStartPoint = 0.0;
|
||||
static CGFloat const kJBLineChartViewDefaultEndPoint = 1.0;
|
||||
static CGFloat const kJBLineChartViewReloadAnimationDuration = 0.1;
|
||||
static CGFloat const kJBLineChartViewDefaultDimmedLineAndFillSelectionOpacity = 0.20f;
|
||||
static CGFloat const kJBLineChartViewDefaultDimmedDotSelectionOpacity = 0.0f;
|
||||
static CGFloat const kJBLineChartViewDefaultStrokeWidth = 5.0f;
|
||||
static NSInteger const kJBLineChartViewDefaultDotRadiusFactor = 3; // 3x size of line width
|
||||
static NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
|
||||
@interface JBChartView (Private)
|
||||
|
||||
@@ -265,7 +266,7 @@ NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
if (self.linesView == nil)
|
||||
{
|
||||
self.linesView = [[JBLineChartLinesView alloc] initWithFrame:linesViewRect];
|
||||
self.linesView.delegate = self;
|
||||
self.linesView.dataSource = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -293,7 +294,7 @@ NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
if (self.dotsView == nil)
|
||||
{
|
||||
self.dotsView = [[JBLineChartDotsView alloc] initWithFrame:dotViewRect];
|
||||
self.dotsView.delegate = self;
|
||||
self.dotsView.dataSource = self;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -396,7 +397,7 @@ NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
[weakSelf.dotsView reloadDataAnimated:YES callback:^{
|
||||
|
||||
JBLineChartDotsView *updatedDotsView = [[JBLineChartDotsView alloc] initWithFrame:weakSelf.dotsView.frame];
|
||||
updatedDotsView.delegate = self;
|
||||
updatedDotsView.dataSource = self;
|
||||
updatedDotsView.alpha = 0.0f;
|
||||
|
||||
// Add updated dots view (hidden)
|
||||
@@ -591,7 +592,7 @@ NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
{
|
||||
return [self.dataSource lineChartView:self dimmedSelectionOpacityAtLineIndex:lineIndex];
|
||||
}
|
||||
return kJBLineChartViewDefaultDimmedSelectionOpacity;
|
||||
return kJBLineChartViewDefaultDimmedLineAndFillSelectionOpacity;
|
||||
}
|
||||
|
||||
- (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView colorForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
@@ -736,6 +737,15 @@ NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dimmedSelectionDotOpacityAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
if ([self.dataSource respondsToSelector:@selector(lineChartView:dimmedSelectionDotOpacityAtLineIndex:)])
|
||||
{
|
||||
return [self.dataSource lineChartView:self dimmedSelectionDotOpacityAtLineIndex:lineIndex];
|
||||
}
|
||||
return kJBLineChartViewDefaultDimmedDotSelectionOpacity;
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)())callback
|
||||
@@ -1053,7 +1063,7 @@ NSInteger const kJBLineChartUnselectedLineIndex = -1;
|
||||
UITouch *touch = [touches anyObject];
|
||||
CGPoint touchPoint = [self clampPoint:[touch locationInView:self.linesView] toBounds:self.linesView.bounds padding:[self padding]];
|
||||
|
||||
NSUInteger lineIndex = self.linesView.selectedLineIndex != kJBLineChartLinesViewUnselectedLineIndex ? self.linesView.selectedLineIndex : [self lineIndexForPoint:touchPoint];
|
||||
NSInteger lineIndex = self.linesView.selectedLineIndex != kJBLineChartLinesViewUnselectedLineIndex ? self.linesView.selectedLineIndex : [self lineIndexForPoint:touchPoint];
|
||||
|
||||
if (lineIndex == kJBLineChartLinesViewUnselectedLineIndex || [((JBLineChartLine *)[self.lineChartLines objectAtIndex:lineIndex]).lineChartPoints count] <= 0)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ extern NSInteger const kJBLineChartDotsViewUnselectedLineIndex;
|
||||
|
||||
@interface JBLineChartDotsView : UIView
|
||||
|
||||
@property (nonatomic, assign) id<JBLineChartDotsViewDataSource> delegate;
|
||||
@property (nonatomic, assign) id<JBLineChartDotsViewDataSource> dataSource;
|
||||
@property (nonatomic, assign) NSInteger selectedLineIndex;
|
||||
@property (nonatomic, strong) NSDictionary *dotViewsDict;
|
||||
|
||||
@@ -42,5 +42,6 @@ extern NSInteger const kJBLineChartDotsViewUnselectedLineIndex;
|
||||
- (UIView *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
||||
- (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
||||
- (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dimmedSelectionDotOpacityAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
@end
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
// Numerics
|
||||
static CGFloat const kJBLineChartDotsViewReloadDataAnimationDuration = 0.15f;
|
||||
NSInteger const kJBLineChartDotsViewUnselectedLineIndex = 0.25f;
|
||||
NSInteger const kJBLineChartDotsViewUnselectedLineIndex = -1;
|
||||
|
||||
@implementation JBLineChartDotsView
|
||||
|
||||
@@ -41,8 +41,8 @@ NSInteger const kJBLineChartDotsViewUnselectedLineIndex = 0.25f;
|
||||
|
||||
- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)())callback
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesForLineChartDotsView:)], @"JBLineChartDotsView // delegate must implement - (NSArray *)lineChartLinesForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView");
|
||||
NSArray *lineChartLines = [self.delegate lineChartLinesForLineChartDotsView:self];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesForLineChartDotsView:)], @"JBLineChartDotsView // dataSource must implement - (NSArray *)lineChartLinesForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView");
|
||||
NSArray *lineChartLines = [self.dataSource lineChartLinesForLineChartDotsView:self];
|
||||
|
||||
if (animated)
|
||||
{
|
||||
@@ -57,8 +57,8 @@ NSInteger const kJBLineChartDotsViewUnselectedLineIndex = 0.25f;
|
||||
NSUInteger lineIndex = 0;
|
||||
for (JBLineChartLine *lineChartLine in lineChartLines)
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:showsDotsForLineAtLineIndex:)], @"JBLineChartDotsView // delegate must implement - (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
if ([self.delegate lineChartDotsView:self showsDotsForLineAtLineIndex:lineIndex]) // line at index contains dots
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:showsDotsForLineAtLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
if ([self.dataSource lineChartDotsView:self showsDotsForLineAtLineIndex:lineIndex]) // line at index contains dots
|
||||
{
|
||||
NSArray *sortedLineChartPoints = [lineChartLine.lineChartPoints sortedArrayUsingSelector:@selector(compare:)];
|
||||
for (NSUInteger horizontalIndex = 0; horizontalIndex < [sortedLineChartPoints count]; horizontalIndex++)
|
||||
@@ -102,8 +102,8 @@ NSInteger const kJBLineChartDotsViewUnselectedLineIndex = 0.25f;
|
||||
NSMutableDictionary *mutableDotViewsDict = [NSMutableDictionary dictionary];
|
||||
for (JBLineChartLine *lineChartLine in lineChartLines)
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:showsDotsForLineAtLineIndex:)], @"JBLineChartDotsView // delegate must implement - (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
if ([self.delegate lineChartDotsView:self showsDotsForLineAtLineIndex:lineIndex]) // line at index contains dots
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:showsDotsForLineAtLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
if ([self.dataSource lineChartDotsView:self showsDotsForLineAtLineIndex:lineIndex]) // line at index contains dots
|
||||
{
|
||||
NSMutableArray *mutableDotViews = [NSMutableArray array];
|
||||
NSArray *sortedLineChartPoints = [lineChartLine.lineChartPoints sortedArrayUsingSelector:@selector(compare:)];
|
||||
@@ -164,24 +164,27 @@ NSInteger const kJBLineChartDotsViewUnselectedLineIndex = 0.25f;
|
||||
{
|
||||
if (weakSelf.selectedLineIndex == lineIndex)
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:selectedColorForDotAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // delegate must implement - (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView selectedColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.backgroundColor = [self.delegate lineChartDotsView:self selectedColorForDotAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:selectedColorForDotAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView selectedColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.backgroundColor = [self.dataSource lineChartDotsView:self selectedColorForDotAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:colorForDotAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // delegate must implement - (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.backgroundColor = [self.delegate lineChartDotsView:self colorForDotAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
dotView.alpha = (weakSelf.selectedLineIndex == kJBLineChartDotsViewUnselectedLineIndex) ? 1.0f : 0.0f; // hide dots on off-selection
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:colorForDotAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.backgroundColor = [self.dataSource lineChartDotsView:self colorForDotAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:dimmedSelectionDotOpacityAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartDotsView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionDotOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.alpha = (weakSelf.selectedLineIndex == kJBLineChartDotsViewUnselectedLineIndex) ? 1.0f : [self.dataSource lineChartDotsView:self dimmedSelectionDotOpacityAtLineIndex:lineIndex];
|
||||
}
|
||||
}
|
||||
// Custom dot
|
||||
else
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:shouldHideDotViewOnSelectionAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // delegate must implement - (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
BOOL hideDotView = [self.delegate lineChartDotsView:self shouldHideDotViewOnSelectionAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:shouldHideDotViewOnSelectionAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
BOOL hideDotView = [self.dataSource lineChartDotsView:self shouldHideDotViewOnSelectionAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
if (weakSelf.selectedLineIndex == lineIndex)
|
||||
{
|
||||
dotView.alpha = hideDotView ? 0.0f : 1.0f;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:dimmedSelectionDotOpacityAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartDotsView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionDotOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.alpha = hideDotView ? [self.dataSource lineChartDotsView:self dimmedSelectionDotOpacityAtLineIndex:lineIndex] : 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -215,19 +218,19 @@ NSInteger const kJBLineChartDotsViewUnselectedLineIndex = 0.25f;
|
||||
|
||||
- (UIView *)dotViewForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:dotViewAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // delegate must implement - (UIView *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
UIView *dotView = [self.delegate lineChartDotsView:self dotViewAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:dotViewAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (UIView *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
UIView *dotView = [self.dataSource lineChartDotsView:self dotViewAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
|
||||
// System dot
|
||||
if (dotView == nil)
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:dotRadiusForLineAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // delegate must implement - (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotRadiusForLineAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
CGFloat dotRadius = [self.delegate lineChartDotsView:self dotRadiusForLineAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:dotRadiusForLineAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotRadiusForLineAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
CGFloat dotRadius = [self.dataSource lineChartDotsView:self dotRadiusForLineAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
|
||||
dotView = [[JBLineChartDotView alloc] initWithRadius:dotRadius];
|
||||
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:colorForDotAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // delegate must implement - (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.backgroundColor = [self.delegate lineChartDotsView:self colorForDotAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartDotsView:colorForDotAtHorizontalIndex:atLineIndex:)], @"JBLineChartDotsView // dataSource must implement - (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex");
|
||||
dotView.backgroundColor = [self.dataSource lineChartDotsView:self colorForDotAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
||||
}
|
||||
|
||||
return dotView;
|
||||
|
||||
@@ -16,7 +16,7 @@ extern NSInteger const kJBLineChartLinesViewUnselectedLineIndex;
|
||||
|
||||
@interface JBLineChartLinesView : UIView
|
||||
|
||||
@property (nonatomic, assign) id<JBLineChartLinesViewDataSource> delegate;
|
||||
@property (nonatomic, assign) id<JBLineChartLinesViewDataSource> dataSource;
|
||||
@property (nonatomic, assign) NSInteger selectedLineIndex; // -1 to unselect
|
||||
|
||||
// Data
|
||||
|
||||
@@ -62,8 +62,8 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
{
|
||||
[super drawRect:rect];
|
||||
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesForLineChartLinesView:)], @"JBLineChartLinesView // delegate must implement - (NSArray *)lineChartLinesForLineChartLinesView:(JBLineChartLinesView *)lineChartLinesView");
|
||||
NSArray *chartData = [self.delegate lineChartLinesForLineChartLinesView:self];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesForLineChartLinesView:)], @"JBLineChartLinesView // dataSource must implement - (NSArray *)lineChartLinesForLineChartLinesView:(JBLineChartLinesView *)lineChartLinesView");
|
||||
NSArray *chartData = [self.dataSource lineChartLinesForLineChartLinesView:self];
|
||||
|
||||
for (NSUInteger lineIndex=0; lineIndex<[chartData count]; lineIndex++)
|
||||
{
|
||||
@@ -90,18 +90,18 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
}
|
||||
|
||||
// Width
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:widthForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView widthForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.lineWidth = [self.delegate lineChartLinesView:self widthForLineAtLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:widthForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView widthForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.lineWidth = [self.dataSource lineChartLinesView:self widthForLineAtLineIndex:lineIndex];
|
||||
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:widthForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView widthForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineFillLayer.lineWidth = [self.delegate lineChartLinesView:self widthForLineAtLineIndex:lineIndex];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:widthForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView widthForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineFillLayer.lineWidth = [self.dataSource lineChartLinesView:self widthForLineAtLineIndex:lineIndex];
|
||||
|
||||
// Colors
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:colorForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView colorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.strokeColor = [self.delegate lineChartLinesView:self colorForLineAtLineIndex:lineIndex].CGColor;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:colorForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView colorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.strokeColor = [self.dataSource lineChartLinesView:self colorForLineAtLineIndex:lineIndex].CGColor;
|
||||
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:fillColorForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineFillLayer.fillColor = [self.delegate lineChartLinesView:self fillColorForLineAtLineIndex:lineIndex].CGColor;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:fillColorForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineFillLayer.fillColor = [self.dataSource lineChartLinesView:self fillColorForLineAtLineIndex:lineIndex].CGColor;
|
||||
|
||||
// Bounds
|
||||
shapeLineLayer.frame = self.bounds;
|
||||
@@ -126,8 +126,8 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
JBGradientLineLayer *gradientLineFillLayer = [self gradientLineLayerForLineIndex:lineIndex filled:YES];
|
||||
if (gradientLineFillLayer == nil)
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:fillGradientForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
gradientLineFillLayer = [[JBGradientLineLayer alloc] initWithGradientLayer:[self.delegate lineChartLinesView:self fillGradientForLineAtLineIndex:lineIndex] tag:lineIndex filled:YES currentPath:nil];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:fillGradientForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
gradientLineFillLayer = [[JBGradientLineLayer alloc] initWithGradientLayer:[self.dataSource lineChartLinesView:self fillGradientForLineAtLineIndex:lineIndex] tag:lineIndex filled:YES currentPath:nil];
|
||||
}
|
||||
gradientLineFillLayer.frame = shapeLineFillLayer.frame;
|
||||
|
||||
@@ -168,8 +168,8 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
JBGradientLineLayer *gradientLineLayer = [self gradientLineLayerForLineIndex:lineIndex filled:NO];
|
||||
if (gradientLineLayer == nil)
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:gradientForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView gradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
gradientLineLayer = [[JBGradientLineLayer alloc] initWithGradientLayer:[self.delegate lineChartLinesView:self gradientForLineAtLineIndex:lineIndex] tag:lineIndex filled:NO currentPath:linePath];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:gradientForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView gradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
gradientLineLayer = [[JBGradientLineLayer alloc] initWithGradientLayer:[self.dataSource lineChartLinesView:self gradientForLineAtLineIndex:lineIndex] tag:lineIndex filled:NO currentPath:linePath];
|
||||
}
|
||||
gradientLineLayer.frame = shapeLineLayer.frame;
|
||||
|
||||
@@ -197,8 +197,8 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
|
||||
- (void)reloadDataAnimated:(BOOL)animated callback:(void (^)())callback
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesForLineChartLinesView:)], @"JBLineChartLinesView // delegate must implement - (NSArray *)lineChartLinesForLineChartLinesView:(JBLineChartLinesView *)lineChartLinesView");
|
||||
NSArray *chartData = [self.delegate lineChartLinesForLineChartLinesView:self];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesForLineChartLinesView:)], @"JBLineChartLinesView // dataSource must implement - (NSArray *)lineChartLinesForLineChartLinesView:(JBLineChartLinesView *)lineChartLinesView");
|
||||
NSArray *chartData = [self.dataSource lineChartLinesForLineChartLinesView:self];
|
||||
|
||||
NSUInteger lineCount = [chartData count];
|
||||
|
||||
@@ -320,18 +320,18 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
// Selected solid fill
|
||||
if (weakSelf.selectedLineIndex >= 0 && ((unsigned)shapeLineLayer.tag == weakSelf.selectedLineIndex))
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:selectionFillColorForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionFillColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.fillColor = [self.delegate lineChartLinesView:self selectionFillColorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:selectionFillColorForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionFillColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.fillColor = [self.dataSource lineChartLinesView:self selectionFillColorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
shapeLineLayer.opacity = 1.0f;
|
||||
}
|
||||
// Unselected solid fill
|
||||
else
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:fillColorForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.fillColor = [self.delegate lineChartLinesView:self fillColorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:fillColorForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.fillColor = [self.dataSource lineChartLinesView:self fillColorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.delegate lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.dataSource lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -339,18 +339,18 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
// Selected solid line
|
||||
if (weakSelf.selectedLineIndex >= 0 && ((unsigned)shapeLineLayer.tag == weakSelf.selectedLineIndex))
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:selectionColorForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.strokeColor = [self.delegate lineChartLinesView:self selectionColorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:selectionColorForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.strokeColor = [self.dataSource lineChartLinesView:self selectionColorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
shapeLineLayer.opacity = 1.0f;
|
||||
}
|
||||
// Unselected solid line
|
||||
else
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:colorForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView colorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.strokeColor = [self.delegate lineChartLinesView:self colorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:colorForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (UIColor *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView colorForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.strokeColor = [self.dataSource lineChartLinesView:self colorForLineAtLineIndex:shapeLineLayer.tag].CGColor;
|
||||
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.delegate lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.dataSource lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,8 +371,8 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
// Selected gradient fill
|
||||
if (weakSelf.selectedLineIndex >= 0 && ((unsigned)shapeLineLayer.tag == weakSelf.selectedLineIndex))
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:selectionFillGradientForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionFillGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *selectedFillGradient = [self.delegate lineChartLinesView:self selectionFillGradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:selectionFillGradientForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionFillGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *selectedFillGradient = [self.dataSource lineChartLinesView:self selectionFillGradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
selectedFillGradient.frame = layer.frame;
|
||||
selectedFillGradient.mask = layer.mask;
|
||||
selectedFillGradient.opacity = 1.0f;
|
||||
@@ -381,12 +381,12 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
// Unselected gradient fill
|
||||
else
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:fillGradientForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *unselectedFillGradient = [self.delegate lineChartLinesView:self fillGradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:fillGradientForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView fillGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *unselectedFillGradient = [self.dataSource lineChartLinesView:self fillGradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
unselectedFillGradient.frame = layer.frame;
|
||||
unselectedFillGradient.mask = layer.mask;
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
unselectedFillGradient.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.delegate lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
unselectedFillGradient.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.dataSource lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
[layersToReplace addObject:@{oldLayerKey: layer, newLayerKey: unselectedFillGradient}];
|
||||
}
|
||||
}
|
||||
@@ -395,8 +395,8 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
// Selected gradient line
|
||||
if (weakSelf.selectedLineIndex >= 0 && ((unsigned)shapeLineLayer.tag == weakSelf.selectedLineIndex))
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:selectionGradientForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *selectedGradient = [self.delegate lineChartLinesView:self selectionGradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:selectionGradientForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView selectionGradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *selectedGradient = [self.dataSource lineChartLinesView:self selectionGradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
selectedGradient.frame = layer.frame;
|
||||
selectedGradient.mask = layer.mask;
|
||||
selectedGradient.opacity = 1.0f;
|
||||
@@ -405,12 +405,12 @@ NSInteger const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
// Unselected gradient line
|
||||
else
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:gradientForLineAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView gradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *unselectedGradient = [self.delegate lineChartLinesView:self gradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:gradientForLineAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CAGradientLayer *)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView gradientForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CAGradientLayer *unselectedGradient = [self.dataSource lineChartLinesView:self gradientForLineAtLineIndex:shapeLineLayer.tag];
|
||||
unselectedGradient.frame = layer.frame;
|
||||
unselectedGradient.mask = layer.mask;
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // delegate must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.delegate lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(lineChartLinesView:dimmedSelectionOpacityAtLineIndex:)], @"JBLineChartLinesView // dataSource must implement - (CGFloat)lineChartLinesView:(JBLineChartLinesView *)lineChartLinesView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex");
|
||||
shapeLineLayer.opacity = (weakSelf.selectedLineIndex == kJBLineChartLinesViewUnselectedLineIndex) ? 1.0f : [self.dataSource lineChartLinesView:self dimmedSelectionOpacityAtLineIndex:shapeLineLayer.tag];
|
||||
[layersToReplace addObject:@{oldLayerKey: layer, newLayerKey: unselectedGradient}];
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -198,8 +198,15 @@ Upon selection, all other lines (+ fills) will be dimmed to 20% opacity (default
|
||||
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dimmedSelectionOpacityAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
// Return new opacity (0.0 to hide completely, and 1.0 to have no effect)
|
||||
// Return unselected line opacity (0.0 to hide completely, and 1.0 to have no effect)
|
||||
}
|
||||
|
||||
The dot selection opacity (default 0%) can also be modified via:
|
||||
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dimmedSelectionDotOpacityAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
// Return unselected dot opacity (0.0 to hide completely and 1.0 to have no effect)
|
||||
}
|
||||
|
||||
If you don't want a line to be selectable:
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "JBChartView"
|
||||
s.version = "3.0.1"
|
||||
s.version = "3.0.5"
|
||||
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.1"
|
||||
:tag => "v3.0.5"
|
||||
}
|
||||
|
||||
s.platform = :ios, '6.0'
|
||||
|
||||
Reference in New Issue
Block a user