Compare commits

...

9 Commits

Author SHA1 Message Date
Terry Worona 43c6e9486f Updated version, pod spec, etc 2014-05-05 12:33:39 -07:00
Terry Worona 49206a01ed Fixed issue #48 2014-05-05 12:31:12 -07:00
Terry Worona e2b17820bf readme updates 2014-05-04 14:47:21 -07:00
Terry Worona b59904e5b9 updated for new version 2014-05-04 14:45:27 -07:00
Terry Worona 1d8f78d751 Fixed issue #48 2014-05-04 14:07:27 -07:00
Terry Worona 3cc39124b8 updated version 2014-05-04 09:48:10 -07:00
terryworona bedd7e2c71 Merge pull request #49 from simonnickel/master
fixed typo, renamed mininum -> minimum
2014-05-04 09:44:03 -07:00
Simon Nickel 786af91666 fixed typo, renamed mininum -> minimum 2014-05-03 22:18:42 +02:00
Terry Worona b7927cddb7 Fixes issue #46 2014-04-30 22:58:47 -07:00
7 changed files with 97 additions and 77 deletions
+16
View File
@@ -1,5 +1,21 @@
# Changelog
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.5.1">2.5.1</a>
#### 05/05/14
- Additional fixes to issue <a href="https://github.com/Jawbone/JBChartView/pull/48">#48</a>.
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.5.0">2.5.0</a>
#### 05/04/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/48">#48</a>.
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.3">2.4.3</a>
#### 05/04/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/49">#49</a>.
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.2">2.4.2</a>
#### 04/30/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/46">#46</a>.
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.1">2.4.1</a>
#### 04/30/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/45">#45</a>.
+18 -33
View File
@@ -18,6 +18,13 @@ NSInteger static const kJBBarChartViewUndefinedBarIndex = -1;
// Colors (JBChartView)
static UIColor *kJBBarChartViewDefaultBarColor = nil;
@interface JBChartView (Private)
- (BOOL)hasMaximumValue;
- (BOOL)hasMinimumValue;
@end
@interface JBBarChartView ()
@property (nonatomic, strong) NSDictionary *chartDataDictionary; // key = column, value = height
@@ -34,8 +41,6 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
// View quick accessors
- (CGFloat)availableHeight;
- (CGFloat)normalizedHeightForRawHeight:(NSNumber*)rawHeight;
- (CGFloat)minHeight;
- (CGFloat)maxHeight;
- (CGFloat)barWidth;
- (CGFloat)popOffset;
@@ -252,8 +257,8 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
- (CGFloat)normalizedHeightForRawHeight:(NSNumber*)rawHeight
{
CGFloat minHeight = [self minHeight];
CGFloat maxHeight = [self maxHeight];
CGFloat minHeight = [self minimumValue];
CGFloat maxHeight = [self maximumValue];
CGFloat value = [rawHeight floatValue];
if ((maxHeight - minHeight) <= 0)
@@ -264,24 +269,6 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
return ((value - minHeight) / (maxHeight - minHeight)) * [self availableHeight];
}
- (CGFloat)minHeight
{
if (self.mininumValue != kJBChartViewUndefinedMinimumValue)
{
return MIN(self.mininumValue, self.cachedMinHeight);
}
return self.cachedMinHeight;
}
- (CGFloat)maxHeight
{
if (self.maximumValue != kJBChartViewUndefinedMaximumValue)
{
return MAX(self.maximumValue, self.cachedMaxHeight);
}
return self.cachedMaxHeight;
}
- (CGFloat)barWidth
{
NSUInteger barCount = [[self.chartDataDictionary allKeys] count];
@@ -380,8 +367,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
if(_cachedMinHeight == kJBBarChartViewUndefinedCachedHeight)
{
// min height is min value across all goals and values
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
NSArray *chartValues = [[NSMutableArray arrayWithArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
_cachedMinHeight = [[chartValues firstObject] floatValue];
}
return _cachedMinHeight;
@@ -391,29 +377,28 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
if (_cachedMaxHeight == kJBBarChartViewUndefinedCachedHeight)
{
// max height is max value across all goals and values
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
NSArray *chartValues = [[NSMutableArray arrayWithArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
_cachedMaxHeight = [[chartValues lastObject] floatValue];
}
return _cachedMaxHeight;
}
- (CGFloat)mininumValue
- (CGFloat)minimumValue
{
if ([super mininumValue] == kJBChartViewUndefinedMinimumValue)
if ([self hasMinimumValue])
{
return self.cachedMinHeight;
return fminf(self.cachedMinHeight, [super minimumValue]);
}
return [super mininumValue];
return self.cachedMinHeight;
}
- (CGFloat)maximumValue
{
if ([super maximumValue] == kJBChartViewUndefinedMaximumValue)
if ([self hasMaximumValue])
{
return self.cachedMaxHeight;
return fmaxf(self.cachedMaxHeight, [super maximumValue]);
}
return [super maximumValue];
return self.cachedMaxHeight;
}
#pragma mark - Touch Helpers
+9 -4
View File
@@ -9,8 +9,6 @@
#import <Foundation/Foundation.h>
extern CGFloat const kJBChartViewDefaultAnimationDuration;
extern CGFloat const kJBChartViewUndefinedMinimumValue; // helper for undefined min/max values
extern CGFloat const kJBChartViewUndefinedMaximumValue;
/**
* At a minimum, a chart can support two states, along with animations to-and-from.
@@ -43,7 +41,10 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
/**
* The minimum and maxmimum values of the chart.
* If no value(s) are supplied, the min and max values of the chart's data source are used.
* If no value(s) are supplied:
*
* minimumValue = chart's data source min value.
* maxmimumValue = chart's data source max value.
*
* If value(s) are supplied, they must be >= 0, otherwise an assertion will be thrown.
* The min/max values are clamped to the ceiling and floor of the actual min/max values of the chart's data source;
@@ -51,9 +52,13 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
*
* For min/max modifications to take effect, reloadData must be called.
*/
@property (nonatomic, assign) CGFloat mininumValue;
@property (nonatomic, assign) CGFloat minimumValue;
@property (nonatomic, assign) CGFloat maximumValue;
// reset to default (chart's data source min & max value)
- (void)resetMinimumValue;
- (void)resetMaximumValue;
/**
* Charts can either be expanded or contracted.
* By default, a chart should be expanded on initialization.
+19 -7
View File
@@ -8,15 +8,17 @@
#import "JBChartView.h"
// Numerics
CGFloat const kJBChartViewDefaultAnimationDuration = 0.25f;
CGFloat const kJBChartViewUndefinedMinimumValue = -1.0f;
CGFloat const kJBChartViewUndefinedMaximumValue = -1.0f;
// Color (JBChartSelectionView)
static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
@interface JBChartView ()
@property (nonatomic, assign) BOOL hasMaximumValue;
@property (nonatomic, assign) BOOL hasMinimumValue;
// Construction
- (void)constructChartView;
@@ -59,8 +61,6 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
- (void)constructChartView
{
self.clipsToBounds = YES;
_mininumValue = kJBChartViewUndefinedMinimumValue;
_maximumValue = kJBChartViewUndefinedMaximumValue;
}
#pragma mark - Public
@@ -138,16 +138,28 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
[self setState:state animated:NO];
}
- (void)setMininumValue:(CGFloat)mininumValue
- (void)setMinimumValue:(CGFloat)minimumValue
{
NSAssert(mininumValue >= 0, @"JBChartView // the minimumValue must be >= 0.");
_mininumValue = mininumValue;
NSAssert(minimumValue >= 0, @"JBChartView // the minimumValue must be >= 0.");
_minimumValue = minimumValue;
_hasMinimumValue = YES;
}
- (void)setMaximumValue:(CGFloat)maximumValue
{
NSAssert(maximumValue >= 0, @"JBChartView // the maximumValue must be >= 0.");
_maximumValue = maximumValue;
_hasMaximumValue = YES;
}
- (void)resetMinimumValue
{
_hasMinimumValue = NO; // clears min
}
- (void)resetMaximumValue
{
_hasMaximumValue = NO; // clears max
}
@end
+16 -29
View File
@@ -50,6 +50,13 @@ static UIColor *kJBLineChartViewDefaultDotColor = nil;
static UIColor *kJBLineChartViewDefaultLineSelectionColor = nil;
static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
@interface JBChartView (Private)
- (BOOL)hasMaximumValue;
- (BOOL)hasMinimumValue;
@end
@interface JBLineLayer : CAShapeLayer
@property (nonatomic, assign) NSUInteger tag;
@@ -149,8 +156,6 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
// View quick accessors
- (CGFloat)normalizedHeightForRawHeight:(CGFloat)rawHeight;
- (CGFloat)availableHeight;
- (CGFloat)minHeight;
- (CGFloat)maxHeight;
- (CGFloat)padding;
- (NSUInteger)dataCount;
@@ -384,8 +389,8 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
- (CGFloat)normalizedHeightForRawHeight:(CGFloat)rawHeight
{
CGFloat minHeight = [self minHeight];
CGFloat maxHeight = [self maxHeight];
CGFloat minHeight = [self minimumValue];
CGFloat maxHeight = [self maximumValue];
if ((maxHeight - minHeight) <= 0)
{
@@ -400,24 +405,6 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
return self.bounds.size.height - self.headerView.frame.size.height - self.footerView.frame.size.height - self.headerPadding;
}
- (CGFloat)minHeight
{
if (self.mininumValue != kJBChartViewUndefinedMinimumValue)
{
return MIN(self.mininumValue, self.cachedMinHeight);
}
return self.cachedMinHeight;
}
- (CGFloat)maxHeight
{
if (self.maximumValue != kJBChartViewUndefinedMaximumValue)
{
return MAX(self.maximumValue, self.cachedMaxHeight);
}
return self.cachedMaxHeight;
}
- (CGFloat)padding
{
CGFloat maxLineWidth = 0.0f;
@@ -724,22 +711,22 @@ static UIColor *kJBLineChartViewDefaultDotSelectionColor = nil;
return _cachedMaxHeight;
}
- (CGFloat)mininumValue
- (CGFloat)minimumValue
{
if ([super mininumValue] == kJBChartViewUndefinedMinimumValue)
if ([self hasMinimumValue])
{
return self.cachedMinHeight;
return fminf(self.cachedMinHeight, [super minimumValue]);
}
return [super mininumValue];
return self.cachedMinHeight;
}
- (CGFloat)maximumValue
{
if ([super maximumValue] == kJBChartViewUndefinedMaximumValue)
if ([self hasMaximumValue])
{
return self.cachedMaxHeight;
return fmaxf(self.cachedMaxHeight, [super maximumValue]);
}
return [super maximumValue];
return self.cachedMaxHeight;
}
#pragma mark - Touch Helpers
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "JBChartView"
s.version = "2.4.1"
s.version = "2.5.1"
s.summary = "Jawbone's iOS-based charting library for both line and bar graphs."
s.homepage = "https://github.com/Jawbone/JBChartView"
@@ -10,10 +10,10 @@ Pod::Spec.new do |s|
s.author = { "Terry Worona" => "tworona@jawbone.com" }
s.source = {
:git => "https://github.com/Jawbone/JBChartView.git",
:tag => "v2.4.1"
:tag => "v2.5.1"
}
s.platform = :ios, '7.0'
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
s.source_files = 'Classes/**/*.{h,m}'
s.requires_arc = true
end
+16 -1
View File
@@ -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.4.1'
pod 'JBChartView', '~> 2.5.1'
### The Old School Way
@@ -229,6 +229,21 @@ Lastly, a line chart's selection events are delegated back via:
}
The <b>touchPoint</b> is especially important as it allows you to add custom elements to your chart during selection events. Refer to the demo project (<b>JBLineChartViewController</b>) to see how a tooltip can be used to display additional information during selection events.
## Minimum & Maximum Values
By default, a chart's minimum and maximum values are equal to the min and max supplied by the dataSource. You can override either value via:
- (void)setMinimumValue:(CGFloat)minimumValue;
- (void)setMaximumValue:(CGFloat)maximumValue;
If value(s) are supplied, they must be >= 0, otherwise an assertion will be thrown. To reset the values back to their original defaults:
- (void)resetMinimumValue;
- (void)resetMaximumValue;
The min/max values are clamped to the ceiling and floor of the actual min/max values of the chart's data source; for example, if a maximumValue of 20 is supplied & the chart's actual max is 100, then 100 will be used. For min/max modifications to take effect, reloadData must be called.
## License