Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 51acae13a1 | |||
| 03217243d9 | |||
| 072e45902d | |||
| 326037ce93 | |||
| f447549666 | |||
| eba1d39ba3 |
@@ -220,7 +220,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ceil(((value - minHeight) / (maxHeight - minHeight)) * [self availableHeight]);
|
||||
return ((value - minHeight) / (maxHeight - minHeight)) * [self availableHeight];
|
||||
}
|
||||
|
||||
- (CGFloat)maxHeight
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "JBChartView"
|
||||
s.version = "1.1.2"
|
||||
s.version = "1.1.3"
|
||||
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 => "v1.1.2"
|
||||
:tag => "v1.1.3"
|
||||
}
|
||||
|
||||
s.platform = :ios, '7.0'
|
||||
|
||||
@@ -215,7 +215,7 @@ static UIColor *kJBLineChartViewDefaultLineColor = nil;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ceil(((rawHeight - minHeight) / (maxHeight - minHeight)) * [self availableHeight]);
|
||||
return ((rawHeight - minHeight) / (maxHeight - minHeight)) * [self availableHeight];
|
||||
}
|
||||
|
||||
- (CGFloat)availableHeight
|
||||
@@ -225,16 +225,20 @@ static UIColor *kJBLineChartViewDefaultLineColor = nil;
|
||||
|
||||
- (CGFloat)maxHeight
|
||||
{
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartView:heightForIndex:)], @"JBLineChartView // delegate must implement - (NSInteger)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index");
|
||||
NSInteger maxHeight = 0;
|
||||
for (NSInteger index=0; index<[self dataCount]; index++)
|
||||
if (self.cachedMaxHeight == kJBLineChartViewUndefinedMaxHeight)
|
||||
{
|
||||
if (([self.delegate lineChartView:self heightForIndex:index]) > maxHeight)
|
||||
NSAssert([self.delegate respondsToSelector:@selector(lineChartView:heightForIndex:)], @"JBLineChartView // delegate must implement - (NSInteger)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index");
|
||||
CGFloat maxHeight = 0;
|
||||
for (NSInteger index=0; index<[self dataCount]; index++)
|
||||
{
|
||||
maxHeight = [self.delegate lineChartView:self heightForIndex:index];
|
||||
if (([self.delegate lineChartView:self heightForIndex:index]) > maxHeight)
|
||||
{
|
||||
maxHeight = [self.delegate lineChartView:self heightForIndex:index];
|
||||
}
|
||||
}
|
||||
self.cachedMaxHeight = maxHeight;
|
||||
}
|
||||
return maxHeight;
|
||||
return self.cachedMaxHeight;
|
||||
}
|
||||
|
||||
- (CGFloat)minHeight
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
#import "JBLineChartFooterView.h"
|
||||
#import "JBChartInformationView.h"
|
||||
|
||||
#define ARC4RANDOM_MAX 0x100000000
|
||||
|
||||
// Numerics
|
||||
CGFloat const kJBLineChartViewControllerChartHeight = 250.0f;
|
||||
CGFloat const kJBLineChartViewControllerChartHeaderHeight = 75.0f;
|
||||
CGFloat const kJBLineChartViewControllerChartHeaderPadding = 20.0f;
|
||||
CGFloat const kJBLineChartViewControllerChartFooterHeight = 20.0f;
|
||||
NSInteger const kJBLineChartViewControllerNumChartPoints = 27;
|
||||
NSInteger const kJBLineChartViewControllerMaxPointValue = 100; // max random value
|
||||
|
||||
// Strings
|
||||
NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
@@ -60,7 +61,7 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
NSMutableArray *mutableChartData = [NSMutableArray array];
|
||||
for (int i=0; i<kJBLineChartViewControllerNumChartPoints; i++)
|
||||
{
|
||||
[mutableChartData addObject:[NSNumber numberWithFloat:arc4random() % kJBLineChartViewControllerMaxPointValue]];
|
||||
[mutableChartData addObject:[NSNumber numberWithFloat:((double)arc4random() / ARC4RANDOM_MAX)]]; // random number between 0 and 1
|
||||
}
|
||||
_chartData = [NSArray arrayWithArray:mutableChartData];
|
||||
}
|
||||
@@ -135,7 +136,7 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectChartAtIndex:(NSInteger)index
|
||||
{
|
||||
NSNumber *valueNumber = [self.chartData objectAtIndex:index];
|
||||
[self.informationView setValueText:[NSString stringWithFormat:@"%d", [valueNumber intValue]] unitText:kJBStringLabelMm];
|
||||
[self.informationView setValueText:[NSString stringWithFormat:@"%.2f", [valueNumber floatValue]] unitText:kJBStringLabelMm];
|
||||
[self.informationView setTitleText:[NSString stringWithFormat:@"%d", [kJBStringLabel1987 intValue] + (int)index]];
|
||||
[self.informationView setHidden:NO animated:YES];
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ Simply add the following line to your <code>Podfile</code>:
|
||||
Your Podfile should look something like:
|
||||
|
||||
platform :ios, '7.0'
|
||||
pod 'JBChartView', '~> 1.1.2'
|
||||
pod 'JBChartView', '~> 1.1.3'
|
||||
|
||||
### The Old School Way
|
||||
|
||||
@@ -52,7 +52,7 @@ Both JBChartView implementations have a similiar data source and delgate pattern
|
||||
|
||||
#### JBBarChartView
|
||||
|
||||
To initialze a <i>JBBarChartView</i>, you only need a few lines of code:
|
||||
To initialize a <i>JBBarChartView</i>, you only need a few lines of code:
|
||||
|
||||
JBBarChartView *barChartView = [[JBBarChartView alloc] init];
|
||||
barChartView.delegate = self;
|
||||
@@ -75,7 +75,7 @@ Secondly, you need to inform the delegate the height of each bar (automatically
|
||||
|
||||
#### JBLineChartView
|
||||
|
||||
Similiarily, to initialze a JBLineChartView, you only need a few lines of code:
|
||||
Similiarily, to initialize a JBLineChartView, you only need a few lines of code:
|
||||
|
||||
JBLineChartView *lineChartView = [[JBLineChartView alloc] init];
|
||||
lineChartView.delegate = self;
|
||||
@@ -176,4 +176,4 @@ A JBLineChartView visuaul overview can be found <a href="https://raw.github.com/
|
||||
|
||||
## License
|
||||
|
||||
Usage is provided under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License</a> (v2.0). See <a href="https://github.com/Jawbone/JBChartView/blob/master/LICENSE">LICENSE</a> for full details.
|
||||
Usage is provided under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License</a> (v2.0). See <a href="https://github.com/Jawbone/JBChartView/blob/master/LICENSE">LICENSE</a> for full details.
|
||||
|
||||
Reference in New Issue
Block a user