Skip to content

Commit

Permalink
Remove redundant maxValue calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuoza committed Jan 31, 2016
1 parent 7e03731 commit d142a43
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/YOChartImageKit/YOBarChartImage.m
Expand Up @@ -26,7 +26,7 @@ - (NSNumber *) maxValue {
- (UIImage *)drawImage:(CGRect)frame scale:(CGFloat)scale {
NSAssert(_values.count > 0, @"YOBarChartImage // must assign values property which is an array of NSNumber");

CGFloat maxValue = _maxValue ? [_maxValue floatValue] : [[_values valueForKeyPath:@"@max.floatValue"] floatValue];
CGFloat maxValue = self.maxValue.floatValue;
CGFloat dataCount = (CGFloat)_values.count;

CGFloat padding;
Expand Down
2 changes: 1 addition & 1 deletion Source/YOChartImageKit/YOLineChartImage.m
Expand Up @@ -22,7 +22,7 @@ - (UIImage *)drawImage:(CGRect)frame scale:(CGFloat)scale {
NSUInteger valuesCount = _values.count;
CGFloat pointX = frame.size.width / (valuesCount - 1);
NSMutableArray<NSValue *> *points = [NSMutableArray array];
CGFloat maxValue = _maxValue ? [_maxValue floatValue] : [[_values valueForKeyPath:@"@max.floatValue"] floatValue];
CGFloat maxValue = self.maxValue.floatValue;

[_values enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *_) {
CGFloat ratioY = number.floatValue / maxValue;
Expand Down

0 comments on commit d142a43

Please sign in to comment.