Created
September 28, 2012 09:21
-
-
Save mrmans0n/3798841 to your computer and use it in GitHub Desktop.
Calculate increment factor for graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Obtenemos el factor de incremento para las graficas | |
- (NSInteger)calculateDividerForMaxValue:(NSNumber*)maxValue withBaseIncrement:(NSInteger)increment { | |
NSInteger resultDivide = [maxValue floatValue] / increment; | |
if (resultDivide<=kGraphMaximumHorizontalLines) { | |
if (resultDivide<kGraphMaximumHorizontalLines/2) { | |
return [self calculateDividerForMaxValue:maxValue withBaseIncrement:increment/2]; | |
} else { | |
return increment; | |
} | |
} | |
NSInteger resultRemainder = resultDivide/kGraphMaximumHorizontalLines; | |
resultRemainder++; | |
return resultRemainder*increment; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment