Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d28b65add | |||
| e72a54356e | |||
| 86440913ba | |||
| c1ac9e4a2f | |||
| 6f185f9e53 | |||
| d142629dd3 |
@@ -39,7 +39,7 @@
|
||||
*
|
||||
* @return The y-axis height of the supplied bar index (x-axis)
|
||||
*/
|
||||
- (NSInteger)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index;
|
||||
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index;
|
||||
|
||||
@optional
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
|
||||
- (void)reloadData
|
||||
{
|
||||
// reset cached max height
|
||||
self.cachedMaxHeight = kJBBarChartViewUndefinedMaxHeight;
|
||||
|
||||
/*
|
||||
* The data collection holds all position information:
|
||||
* constructed via datasource and delegate functions
|
||||
@@ -93,7 +96,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
|
||||
NSMutableDictionary *dataDictionary = [NSMutableDictionary dictionary];
|
||||
for (NSInteger index=0; index<dataCount; index++)
|
||||
{
|
||||
[dataDictionary setObject:[NSNumber numberWithInt:(int)[self.delegate barChartView:self heightForBarViewAtAtIndex:index]] forKey:[NSNumber numberWithInt:(int)index]];
|
||||
[dataDictionary setObject:[NSNumber numberWithFloat:[self.delegate barChartView:self heightForBarViewAtAtIndex:index]] forKey:[NSNumber numberWithInt:(int)index]];
|
||||
}
|
||||
self.chartDataDictionary = [NSDictionary dictionaryWithDictionary:dataDictionary];
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "JBChartView"
|
||||
s.version = "1.1.0"
|
||||
s.version = "1.1.2"
|
||||
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.0"
|
||||
:tag => "v1.1.2"
|
||||
}
|
||||
|
||||
s.platform = :ios, '7.0'
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
* the chart will automatically normalize all values between the overal min and max heights.
|
||||
*
|
||||
* @param lineChartView The origin chart
|
||||
* @param index The 0-based index of a given line height (left to right, x-axis)
|
||||
* @param index The 0-based index of a given line height (left to right, x-axis)
|
||||
*
|
||||
* @return The y-axis value of the supplied line index (x-axis)
|
||||
*/
|
||||
- (NSInteger)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index;
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index;
|
||||
|
||||
@optional
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
* and the selection must occur within the bounds of the chart.
|
||||
*
|
||||
* @param lineChartView The origin chart
|
||||
* @param index The 0-based index of a selection point (left to right, x-axis)
|
||||
* @param index The 0-based index of a selection point (left to right, x-axis)
|
||||
*/
|
||||
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectChartAtIndex:(NSInteger)index;
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* For selection start events, see: didSelectChartAtIndex...
|
||||
*
|
||||
* @param lineChartView The origin chart
|
||||
* @param index The 0-based index of a selection point. Index will be -1 if the touch ends outside of the view's bounds.
|
||||
* @param index The 0-based index of a selection point. Index will be -1 if the touch ends outside of the view's bounds.
|
||||
*/
|
||||
- (void)lineChartView:(JBLineChartView *)lineChartView didUnselectChartAtIndex:(NSInteger)index;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ static UIColor *kJBLineChartViewDefaultLineColor = nil;
|
||||
@property (nonatomic, assign) BOOL selectionViewVisible;
|
||||
|
||||
// View quick accessors
|
||||
- (CGFloat)normalizedHeightForRawHeight:(NSInteger)rawHeight;
|
||||
- (CGFloat)normalizedHeightForRawHeight:(CGFloat)rawHeight;
|
||||
- (CGFloat)availableHeight;
|
||||
- (CGFloat)maxHeight;
|
||||
- (CGFloat)minHeight;
|
||||
@@ -117,6 +117,9 @@ static UIColor *kJBLineChartViewDefaultLineColor = nil;
|
||||
|
||||
- (void)reloadData
|
||||
{
|
||||
// reset cached max height
|
||||
self.cachedMaxHeight = kJBLineChartViewUndefinedMaxHeight;
|
||||
|
||||
/*
|
||||
* Subview rectangle calculations
|
||||
*/
|
||||
@@ -138,11 +141,10 @@ static UIColor *kJBLineChartViewDefaultLineColor = nil;
|
||||
for (NSInteger index=0; index<[self dataCount]; index++)
|
||||
{
|
||||
JBLineChartPoint *chartPoint = [[JBLineChartPoint alloc] init];
|
||||
NSInteger rawHeight = [self.delegate lineChartView:self heightForIndex:index];
|
||||
CGFloat rawHeight = [self.delegate lineChartView:self heightForIndex:index];
|
||||
CGFloat normalizedHeight = [self normalizedHeightForRawHeight:rawHeight];
|
||||
yOffset = mainViewRect.size.height - normalizedHeight;
|
||||
|
||||
//yOffset = mainViewRect.size.height - yOffset;
|
||||
chartPoint.position = CGPointMake(xOffset, yOffset);
|
||||
|
||||
[mutableChartData addObject:chartPoint];
|
||||
@@ -203,7 +205,7 @@ static UIColor *kJBLineChartViewDefaultLineColor = nil;
|
||||
|
||||
#pragma mark - View Quick Accessors
|
||||
|
||||
- (CGFloat)normalizedHeightForRawHeight:(NSInteger)rawHeight
|
||||
- (CGFloat)normalizedHeightForRawHeight:(CGFloat)rawHeight
|
||||
{
|
||||
CGFloat minHeight = [self minHeight];
|
||||
CGFloat maxHeight = [self maxHeight];
|
||||
|
||||
@@ -65,7 +65,7 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
|
||||
NSMutableArray *mutableChartData = [NSMutableArray array];
|
||||
for (int i=0; i<kJBBarChartViewControllerNumBars; i++)
|
||||
{
|
||||
[mutableChartData addObject:[NSNumber numberWithInteger:MAX(kJBBarChartViewControllerMinBarHeight, arc4random() % kJBBarChartViewControllerMaxBarHeight)]]; // fake height
|
||||
[mutableChartData addObject:[NSNumber numberWithFloat:MAX(kJBBarChartViewControllerMinBarHeight, arc4random() % kJBBarChartViewControllerMaxBarHeight)]]; // fake height
|
||||
}
|
||||
_chartData = [NSArray arrayWithArray:mutableChartData];
|
||||
}
|
||||
@@ -120,9 +120,9 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
|
||||
|
||||
#pragma mark - JBBarChartViewDelegate
|
||||
|
||||
- (NSInteger)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index
|
||||
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index
|
||||
{
|
||||
return [[self.chartData objectAtIndex:index] intValue];
|
||||
return [[self.chartData objectAtIndex:index] floatValue];
|
||||
}
|
||||
|
||||
#pragma mark - JBBarChartViewDataSource
|
||||
|
||||
@@ -60,7 +60,7 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
NSMutableArray *mutableChartData = [NSMutableArray array];
|
||||
for (int i=0; i<kJBLineChartViewControllerNumChartPoints; i++)
|
||||
{
|
||||
[mutableChartData addObject:[NSNumber numberWithInteger:arc4random() % kJBLineChartViewControllerMaxPointValue]];
|
||||
[mutableChartData addObject:[NSNumber numberWithFloat:arc4random() % kJBLineChartViewControllerMaxPointValue]];
|
||||
}
|
||||
_chartData = [NSArray arrayWithArray:mutableChartData];
|
||||
}
|
||||
@@ -127,9 +127,9 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
|
||||
|
||||
#pragma mark - JBLineChartViewDelegate
|
||||
|
||||
- (NSInteger)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index
|
||||
{
|
||||
return [[self.chartData objectAtIndex:index] intValue];
|
||||
return [[self.chartData objectAtIndex:index] floatValue];
|
||||
}
|
||||
|
||||
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectChartAtIndex:(NSInteger)index
|
||||
|
||||
@@ -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.0'
|
||||
pod 'JBChartView', '~> 1.1.2'
|
||||
|
||||
### The Old School Way
|
||||
|
||||
@@ -68,7 +68,7 @@ At a minimum, you need to inform the data source how many bars are in the chart:
|
||||
|
||||
Secondly, you need to inform the delegate the height of each bar (automatically normalized across the entire chart):
|
||||
|
||||
- (NSInteger)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index
|
||||
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index
|
||||
{
|
||||
return ...; // height of bar at index
|
||||
}
|
||||
@@ -91,7 +91,7 @@ At a minimum, you need to inform the data source how many points are in the line
|
||||
|
||||
Secondly, you need to inform the delegate the y-position of each point (automatically normalized across the entire chart):
|
||||
|
||||
- (NSInteger)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index
|
||||
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView heightForIndex:(NSInteger)index
|
||||
{
|
||||
return ...; // y-position of poinnt at index (x-axis)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user