|
|
|
@@ -139,6 +139,7 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView widthForLineAtLineIndex:(NSUInteger)lineIndex;
|
|
|
|
|
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotRadiusForLineAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
|
|
|
|
- (UIView *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
|
|
|
|
- (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
|
|
|
|
|
- (CGFloat)paddingForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView;
|
|
|
|
|
- (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
|
|
|
|
|
|
|
|
@@ -266,7 +267,8 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
|
|
|
|
|
NSMutableArray *mutableChartData = [NSMutableArray array];
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
NSInteger numberOfLines = [self.dataSource numberOfLinesInLineChartView:self];
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(lineChartView:numberOfVerticalValuesAtLineIndex:)], @"JBLineChartView // dataSource must implement - (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex");
|
|
|
|
|
NSUInteger dataCount = [self.dataSource lineChartView:self numberOfVerticalValuesAtLineIndex:lineIndex];
|
|
|
|
@@ -436,8 +438,9 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
{
|
|
|
|
|
CGFloat maxLineWidth = 0.0f;
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
NSInteger numberOfLines = [self.dataSource numberOfLinesInLineChartView:self];
|
|
|
|
|
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
BOOL showsDots = NO;
|
|
|
|
|
if ([self.dataSource respondsToSelector:@selector(lineChartView:showsDotsForLineAtLineIndex:)])
|
|
|
|
@@ -454,8 +457,7 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
CGFloat maxDotLength = 0;
|
|
|
|
|
if (showsDots)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(lineChartView:numberOfVerticalValuesAtLineIndex:)], @"JBLineChartView // dataSource must implement - (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex");
|
|
|
|
|
NSUInteger dataCount = [self.dataSource lineChartView:self numberOfVerticalValuesAtLineIndex:lineIndex];
|
|
|
|
@@ -539,7 +541,8 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
{
|
|
|
|
|
NSUInteger dataCount = 0;
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
NSInteger numberOfLines = [self.dataSource numberOfLinesInLineChartView:self];
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(lineChartView:numberOfVerticalValuesAtLineIndex:)], @"JBLineChartView // dataSource must implement - (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex");
|
|
|
|
|
NSUInteger lineDataCount = [self.dataSource lineChartView:self numberOfVerticalValuesAtLineIndex:lineIndex];
|
|
|
|
@@ -678,6 +681,15 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
|
|
|
|
|
{
|
|
|
|
|
if ([self.dataSource respondsToSelector:@selector(lineChartView:shouldHideDotViewOnSelectionAtHorizontalIndex:atLineIndex:)])
|
|
|
|
|
{
|
|
|
|
|
return [self.dataSource lineChartView:self shouldHideDotViewOnSelectionAtHorizontalIndex:horizontalIndex atLineIndex:lineIndex];
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (CGFloat)paddingForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView
|
|
|
|
|
{
|
|
|
|
|
return [self padding];
|
|
|
|
@@ -764,7 +776,8 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
{
|
|
|
|
|
CGFloat minHeight = FLT_MAX;
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
NSInteger numberOfLines = [self.dataSource numberOfLinesInLineChartView:self];
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(lineChartView:numberOfVerticalValuesAtLineIndex:)], @"JBLineChartView // dataSource must implement - (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex");
|
|
|
|
|
NSUInteger dataCount = [self.dataSource lineChartView:self numberOfVerticalValuesAtLineIndex:lineIndex];
|
|
|
|
@@ -790,7 +803,8 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
{
|
|
|
|
|
CGFloat maxHeight = 0;
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
NSInteger numberOfLines = [self.dataSource numberOfLinesInLineChartView:self];
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(lineChartView:numberOfVerticalValuesAtLineIndex:)], @"JBLineChartView // dataSource must implement - (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex");
|
|
|
|
|
NSUInteger dataCount = [self.dataSource lineChartView:self numberOfVerticalValuesAtLineIndex:lineIndex];
|
|
|
|
@@ -886,9 +900,10 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
NSUInteger shortestDistance = INT_MAX;
|
|
|
|
|
NSInteger selectedIndex = kJBLineChartUnselectedLineIndex;
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
|
|
|
|
NSInteger numberOfLines = [self.dataSource numberOfLinesInLineChartView:self];
|
|
|
|
|
|
|
|
|
|
// Iterate all lines
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
|
|
|
|
for (NSUInteger lineIndex=0; lineIndex<numberOfLines; lineIndex++)
|
|
|
|
|
{
|
|
|
|
|
NSAssert([self.dataSource respondsToSelector:@selector(lineChartView:numberOfVerticalValuesAtLineIndex:)], @"JBLineChartView // dataSource must implement - (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex");
|
|
|
|
|
if ([self.dataSource lineChartView:self numberOfVerticalValuesAtLineIndex:lineIndex] > rightHorizontalIndex)
|
|
|
|
@@ -1511,7 +1526,16 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
|
|
|
|
|
// Custom dot
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dotView.alpha = (weakSelf.selectedLineIndex == lineIndex) ? 0.0f : 1.0f; // hide custom dots on selection
|
|
|
|
|
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];
|
|
|
|
|
if (weakSelf.selectedLineIndex == lineIndex)
|
|
|
|
|
{
|
|
|
|
|
dotView.alpha = hideDotView ? 0.0f : 1.0f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dotView.alpha = 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
horizontalIndex++;
|
|
|
|
|