Check out the yAxis on the scale. Notice how there are 3 points for 136.6 and 3 points for 136.4... but only one point for 136.5.
These kinds of situations tend to correct themselves over time, but it would be nice if they didn't show up.
Here is the yAxis formatter...
-(NSNumberFormatter*)yAxisLabelFormatter
{
if(!_yAxisLabelFormatter)
_yAxisLabelFormatter = [[NSNumberFormatter alloc] init];
_yAxisLabelFormatter.numberStyle = NSNumberFormatterDecimalStyle;
_yAxisLabelFormatter.groupingSize = 0;
_yAxisLabelFormatter.maximumFractionDigits = 1;
_yAxisLabelFormatter.minimumSignificantDigits = 1;
_yAxisLabelFormatter.minimumFractionDigits = 0;
}
return _yAxisLabelFormatter;
And it's being used as you'd expect...
-(NSString*)chartView:(IGChartView*)chartView
labelForAxis:(IGAxis*)axis
withItem:(NSObject*)item
NSString *label = nil;
if ([axis isKindOfClass:[IGNumericYAxis class]])
label = [self.yAxisLabelFormatter stringFromNumber:((NSNumber*)item)];
.....
Hey Caylan,
There seems to be an oddity in the NSNumberFormatter which is contributing to the issue
If you tried the following code snippet out you would see what we are seeing here
NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
formatter.maximumFractionDigits = 1;
[formatter stringFromNumber:@1.15] 1.2
[formatter stringFromNumber:@1.20] 1.2
[formatter stringFromNumber:@1.25] 1.2
[formatter stringFromNumber:@1.30] 1.3
[formatter stringFromNumber:@1.35] 1.4
[formatter stringFromNumber:@1.40] 1.4
[formatter stringFromNumber:@1.45] 1.4
As for a fix, well the only thing that I can think of would be to ensure your y range wouldn't do this would be to adjust your min/max on the axis along with the interval to prevent .5 rounding.
Another thing you might try is to set
formatter.roundingMode = NSNumberFormatterRoundHalfUp;
In the sample code it prevents the 3.1.3 pattern and makes it 2.2.2 which is what I would expect.
Thank you for looking into this and providing the feedback. It really helps.