Merge pull request #168 from nenuadrian/patch-3
getAxisMinMax - Determine these values automagically
Showing
1 changed file
with
18 additions
and
0 deletions
| @@ -156,6 +156,24 @@ | @@ -156,6 +156,24 @@ | ||
| 156 | } | 156 | } |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | +- (NSArray*) getAxisMinMax:(NSArray*)xValues | ||
| 160 | +{ | ||
| 161 | + float min = [xValues[0] floatValue]; | ||
| 162 | + float max = [xValues[0] floatValue]; | ||
| 163 | + for (NSNumber *number in xValues) | ||
| 164 | + { | ||
| 165 | + if ([number floatValue] > max) | ||
| 166 | + max = [number floatValue]; | ||
| 167 | + | ||
| 168 | + if ([number floatValue] < min) | ||
| 169 | + min = [number floatValue]; | ||
| 170 | + } | ||
| 171 | + NSArray *result = @[[NSNumber numberWithFloat:min], [NSNumber numberWithFloat:max]]; | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + return result; | ||
| 175 | +} | ||
| 176 | + | ||
| 159 | - (void)setAxisXLabel:(NSArray *)array { | 177 | - (void)setAxisXLabel:(NSArray *)array { |
| 160 | if(array.count == ++_AxisX_partNumber){ | 178 | if(array.count == ++_AxisX_partNumber){ |
| 161 | [_axisX_labels removeAllObjects]; | 179 | [_axisX_labels removeAllObjects]; |
-
Please register or login to post a comment