Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7734ef189 | |||
| f6d2fe8b62 | |||
| 5c9679f448 | |||
| 037225a386 | |||
| 0fe979bd22 | |||
| 31b64ed7e4 | |||
| c30398c3ea | |||
| bc08322a3a | |||
| 213973f4ed | |||
| 28d40bcb31 |
@@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.6">2.1.6</a>
|
||||
#### 04/11/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/33">#33</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.5">2.1.5</a>
|
||||
#### 04/10/14
|
||||
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/30">#30</a>.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.4">2.1.4</a>
|
||||
#### 04/10/14
|
||||
- Added ability to specify a radius for dotted lines.
|
||||
|
||||
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.3">2.1.3</a>
|
||||
#### 04/03/14
|
||||
- Added the ability to force a chart's state.
|
||||
|
||||
+25
-4
@@ -17,6 +17,10 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
|
||||
@interface JBChartView ()
|
||||
|
||||
// Construction
|
||||
- (void)constructChartView;
|
||||
|
||||
// Validation
|
||||
- (void)validateHeaderAndFooterHeights;
|
||||
|
||||
@end
|
||||
@@ -25,14 +29,22 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
|
||||
#pragma mark - Alloc/Init
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self)
|
||||
{
|
||||
[self constructChartView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
self.clipsToBounds = YES;
|
||||
_mininumValue = kJBChartViewUndefinedMinimumValue;
|
||||
_maximumValue = kJBChartViewUndefinedMaximumValue;
|
||||
[self constructChartView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -42,6 +54,15 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
return [self initWithFrame:CGRectZero];
|
||||
}
|
||||
|
||||
#pragma mark - Construction
|
||||
|
||||
- (void)constructChartView
|
||||
{
|
||||
self.clipsToBounds = YES;
|
||||
_mininumValue = kJBChartViewUndefinedMinimumValue;
|
||||
_maximumValue = kJBChartViewUndefinedMaximumValue;
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
- (void)reloadData
|
||||
@@ -49,7 +70,7 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
|
||||
// Override
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
#pragma mark - Validation
|
||||
|
||||
- (void)validateHeaderAndFooterHeights
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "JBChartView"
|
||||
s.version = "2.1.3"
|
||||
s.version = "2.1.6"
|
||||
s.summary = "Jawbone's iOS-based charting library for both line and bar graphs."
|
||||
s.homepage = "https://github.com/Jawbone/JBChartView"
|
||||
|
||||
@@ -8,7 +8,7 @@ Pod::Spec.new do |s|
|
||||
s.author = { "Terry Worona" => "tworona@jawbone.com" }
|
||||
s.source = {
|
||||
:git => "https://github.com/Jawbone/JBChartView.git",
|
||||
:tag => "v2.1.3"
|
||||
:tag => "v2.1.6"
|
||||
}
|
||||
|
||||
s.platform = :ios, '7.0'
|
||||
|
||||
@@ -138,6 +138,20 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
|
||||
*/
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView widthForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the radius of all dots in a particular line at lineIndex within the chart.
|
||||
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
|
||||
* Any value can be returned for lineIndex's that don't support dots, as it will never be called.
|
||||
*
|
||||
* Default: line width x 3.
|
||||
*
|
||||
* @param lineChartView The line chart object requesting this information.
|
||||
* @param lineIndex An index number identifying a line in the chart.
|
||||
*
|
||||
* @return The radius of the dots within a dotted line in the chart.
|
||||
*/
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
/**
|
||||
* Returns the (vertical) selection color to be overlayed on the chart during touch events.
|
||||
* The color is automically faded to transparent (vertically). The property showsVerticalSelection
|
||||
|
||||
+55
-18
@@ -26,7 +26,7 @@ CGFloat static const kJBLineChartLinesViewDefaultDimmedOpacity = 0.5f;
|
||||
NSInteger static const kJBLineChartLinesViewUnselectedLineIndex = -1;
|
||||
|
||||
// Numerics (JBLineChartDotsView)
|
||||
NSInteger static const kJBLineChartDotsViewRadiusFactor = 3; // 3x size of line width
|
||||
NSInteger static const kJBLineChartDotsViewDefaultRadiusFactor = 3; // 3x size of line width
|
||||
NSInteger static const kJBLineChartDotsViewUnselectedLineIndex = -1;
|
||||
|
||||
// Numerics (JBLineSelectionView)
|
||||
@@ -115,6 +115,7 @@ static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
|
||||
- (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView colorForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
- (UIColor *)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView selectedColorForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView widthForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
- (CGFloat)paddingForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView;
|
||||
- (BOOL)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
@@ -406,21 +407,39 @@ static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
|
||||
|
||||
- (CGFloat)padding
|
||||
{
|
||||
if ([self.dataSource respondsToSelector:@selector(lineChartView:widthForLineAtLineIndex:)])
|
||||
CGFloat maxLineWidth = 0.0f;
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
||||
|
||||
for (int lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
||||
{
|
||||
NSAssert([self.dataSource respondsToSelector:@selector(numberOfLinesInLineChartView:)], @"JBLineChartView // dataSource must implement - (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView");
|
||||
CGFloat maxWidth = 0.0f;
|
||||
for (int lineIndex=0; lineIndex<[self.dataSource numberOfLinesInLineChartView:self]; lineIndex++)
|
||||
BOOL showsDots = NO;
|
||||
if ([self.dataSource respondsToSelector:@selector(lineChartView:showsDotsForLineAtLineIndex:)])
|
||||
{
|
||||
CGFloat lineWidth = [self.dataSource lineChartView:self widthForLineAtLineIndex:lineIndex];
|
||||
if (lineWidth > maxWidth)
|
||||
showsDots = [self.dataSource lineChartView:self showsDotsForLineAtLineIndex:lineIndex];
|
||||
}
|
||||
|
||||
CGFloat lineWidth = kJBLineChartLinesViewStrokeWidth; // default
|
||||
if ([self.dataSource respondsToSelector:@selector(lineChartView:widthForLineAtLineIndex:)])
|
||||
{
|
||||
lineWidth = [self.dataSource lineChartView:self widthForLineAtLineIndex:lineWidth];
|
||||
}
|
||||
|
||||
CGFloat dotRadius = lineWidth * kJBLineChartDotsViewDefaultRadiusFactor; // default
|
||||
if (showsDots)
|
||||
{
|
||||
if ([self.dataSource respondsToSelector:@selector(lineChartView:dotRadiusForLineAtLineIndex:)])
|
||||
{
|
||||
maxWidth = lineWidth;
|
||||
dotRadius = [self.dataSource lineChartView:self dotRadiusForLineAtLineIndex:lineIndex];
|
||||
}
|
||||
}
|
||||
return ceil(maxWidth * 0.5);
|
||||
|
||||
CGFloat currentMaxLineWidth = MAX(dotRadius, lineWidth);
|
||||
if (currentMaxLineWidth > maxLineWidth)
|
||||
{
|
||||
maxLineWidth = currentMaxLineWidth;
|
||||
}
|
||||
}
|
||||
return ceil(kJBLineChartLinesViewStrokeWidth * 0.5);
|
||||
return ceil(maxLineWidth * 0.5);
|
||||
}
|
||||
|
||||
- (NSUInteger)dataCount
|
||||
@@ -530,6 +549,18 @@ static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
|
||||
return kJBLineChartLinesViewStrokeWidth;
|
||||
}
|
||||
|
||||
- (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
if ([self.dataSource respondsToSelector:@selector(lineChartView:dotRadiusForLineAtLineIndex:)])
|
||||
{
|
||||
return [self.dataSource lineChartView:self dotRadiusForLineAtLineIndex:lineIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self lineChartDotsView:lineChartDotsView widthForLineAtLineIndex:lineIndex] * kJBLineChartDotsViewDefaultRadiusFactor;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)paddingForLineChartDotsView:(JBLineChartDotsView *)lineChartDotsView
|
||||
{
|
||||
return [self padding];
|
||||
@@ -816,8 +847,12 @@ static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
|
||||
{
|
||||
[self.delegate didUnselectLineInLineChartView:self];
|
||||
}
|
||||
[self.linesView setSelectedLineIndex:kJBLineChartLinesViewUnselectedLineIndex animated:YES];
|
||||
[self.dotsView setSelectedLineIndex:kJBLineChartDotsViewUnselectedLineIndex animated:YES];
|
||||
|
||||
if (self.showsLineSelection)
|
||||
{
|
||||
[self.linesView setSelectedLineIndex:kJBLineChartLinesViewUnselectedLineIndex animated:YES];
|
||||
[self.dotsView setSelectedLineIndex:kJBLineChartDotsViewUnselectedLineIndex animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Setters
|
||||
@@ -857,8 +892,11 @@ static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
|
||||
{
|
||||
UITouch *touch = [touches anyObject];
|
||||
CGPoint touchPoint = [self clampPoint:[touch locationInView:self.linesView] toBounds:self.linesView.bounds padding:[self padding]];
|
||||
[self.linesView setSelectedLineIndex:[self lineIndexForPoint:touchPoint] animated:YES];
|
||||
[self.dotsView setSelectedLineIndex:[self lineIndexForPoint:touchPoint] animated:YES];
|
||||
if (self.showsLineSelection)
|
||||
{
|
||||
[self.linesView setSelectedLineIndex:[self lineIndexForPoint:touchPoint] animated:YES];
|
||||
[self.dotsView setSelectedLineIndex:[self lineIndexForPoint:touchPoint] animated:YES];
|
||||
}
|
||||
[self touchesBeganOrMovedWithTouches:touches];
|
||||
}
|
||||
|
||||
@@ -1160,10 +1198,9 @@ static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
|
||||
{
|
||||
NSMutableArray *mutableDotViews = [NSMutableArray array];
|
||||
for (JBLineChartPoint *lineChartPoint in [lineData sortedArrayUsingSelector:@selector(compare:)])
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:widthForLineAtLineIndex:)], @"JBLineChartDotsView // delegate must implement - (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView widthForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CGFloat lineWidth = [self.delegate lineChartDotsView:self widthForLineAtLineIndex:lineIndex];
|
||||
CGFloat dotRadius = lineWidth * kJBLineChartDotsViewRadiusFactor;
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartDotsView:dotRadiusForLineAtLineIndex:)], @"JBLineChartDotsView // delegate must implement - (CGFloat)lineChartDotsView:(JBLineChartDotsView *)lineChartDotsView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex");
|
||||
CGFloat dotRadius = [self.delegate lineChartDotsView:self dotRadiusForLineAtLineIndex:lineIndex];
|
||||
|
||||
JBLineChartDotView *dotView = [[JBLineChartDotView alloc] initWithRadius:dotRadius];
|
||||
dotView.center = CGPointMake(lineChartPoint.position.x, fmin(self.bounds.size.height - padding, fmax(padding, lineChartPoint.position.y)));
|
||||
|
||||
@@ -216,6 +216,11 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
return (lineIndex == JBLineChartLineSolid) ? kJBLineChartViewControllerChartSolidLineWidth: kJBLineChartViewControllerChartDashedLineWidth;
|
||||
}
|
||||
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex
|
||||
{
|
||||
return (lineIndex == JBLineChartLineSolid) ? 0.0: (kJBLineChartViewControllerChartDashedLineWidth * 4);
|
||||
}
|
||||
|
||||
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView
|
||||
{
|
||||
return [UIColor whiteColor];
|
||||
|
||||
@@ -38,7 +38,7 @@ Simply add the following line to your <code>Podfile</code>:
|
||||
Your Podfile should look something like:
|
||||
|
||||
platform :ios, '7.0'
|
||||
pod 'JBChartView', '~> 2.1.3'
|
||||
pod 'JBChartView', '~> 2.1.6'
|
||||
|
||||
### The Old School Way
|
||||
|
||||
@@ -196,6 +196,10 @@ Furthermore, the color of the selection bar and line can be customized via the <
|
||||
By default, each line will not show dots for each point. To enable this on a per-line basis:
|
||||
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
To customize the size of each dot, implement (default is 3x the line width):
|
||||
|
||||
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
|
||||
|
||||
As well, by default, each line will have squared off end caps and connection points. To enable line smoothing:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user