Merge pull request #173 from ArcadiaConsulting/master
Avoid labels on Y axis duplicate
Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -68,6 +68,10 @@ | @@ -68,6 +68,10 @@ | ||
| 68 | { | 68 | { |
| 69 | _yValues = yValues; | 69 | _yValues = yValues; |
| 70 | 70 | ||
| 71 | + //make the _yLabelSum value dependant of the distinct values of yValues to avoid duplicates on yAxis | ||
| 72 | + int yLabelsDifTotal = [NSSet setWithArray:yValues].count; | ||
| 73 | + _yLabelSum = yLabelsDifTotal % 2 == 0 ? yLabelsDifTotal : yLabelsDifTotal + 1; | ||
| 74 | + | ||
| 71 | if (_yMaxValue) { | 75 | if (_yMaxValue) { |
| 72 | _yValueMax = _yMaxValue; | 76 | _yValueMax = _yMaxValue; |
| 73 | } else { | 77 | } else { |
| @@ -114,7 +118,8 @@ | @@ -114,7 +118,8 @@ | ||
| 114 | { | 118 | { |
| 115 | int max = [[yLabels valueForKeyPath:@"@max.intValue"] intValue]; | 119 | int max = [[yLabels valueForKeyPath:@"@max.intValue"] intValue]; |
| 116 | 120 | ||
| 117 | - _yValueMax = (int)max; | 121 | + //ensure max is even |
| 122 | + _yValueMax = max % 2 == 0 ? max : max + 1; | ||
| 118 | 123 | ||
| 119 | if (_yValueMax == 0) { | 124 | if (_yValueMax == 0) { |
| 120 | _yValueMax = _yMinValue; | 125 | _yValueMax = _yMinValue; |
-
Please register or login to post a comment