Carlos Pérez
Committed by Carlos Pérez Horga

Modify on PNBarChart.m the setYValues method to make the number of labels on Y a…

…xis (_yLabelSum) depends on the number of different Y values, avoiding the  duplicate labels on Y axis.
Also modify getYValueMax and setYValues methods to ensure the max value of Y axis (_yValueMax) and the number of labels on Y axis (_yLabelSum) are even to avoid when the Y labels hasn't decimal values (default value for _yLabelFormatter) the axis label position not match with the value
@@ -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;