Problem: I can't get Core Plot (1.1) to plot automatic labels for my x-axis when using autoscaling ([plotSpace scaleToFitPlots:[graph allPlots]).
What I have tried: I changed the values for the offsets and paddings, but this did not change the result.
However, when turning autoscale off (not using [plotSpace scaleToFitPlots:[graph allPlots]]and setting the y scale automatically, the automatic labeling of the x-axis works.
Question: Is there a bug in Core Plot or what did I do wrong?
I would appreciate any help!
Thank you!
This is how I have set up my chart:
CPTBarPlot *barPlot = [CPTBarPlot
tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO];
barPlot.baseValue = CPTDecimalFromInt(0);
barPlot.barOffset = CPTDecimalFromFloat(0.0f); // CPTDecimalFromFloat(0.5f);
barPlot.barWidth = CPTDecimalFromFloat(0.4f);
barPlot.barCornerRadius = 4;
barPlot.labelOffset = 5;
barPlot.dataSource = self;
barPlot.delegate = self;
graph = [[CPTXYGraph alloc]initWithFrame:self.view.bounds];
self.hostView.hostedGraph = graph;
graph.paddingLeft = 40.0f;
graph.paddingTop = 30.0f;
graph.paddingRight = 30.0f;
graph.paddingBottom = 50.0f;
[graph addPlot:barPlot];
graph.plotAreaFrame.masksToBorder = NO;
graph.plotAreaFrame.cornerRadius = 0.0f;
graph.plotAreaFrame.borderLineStyle = borderLineStyle;
double xAxisStart = 0;
CPTXYAxisSet *xyAxisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *xAxis = xyAxisSet.xAxis;
CPTMutableLineStyle *lineStyle = [xAxis.axisLineStyle mutableCopy];
lineStyle.lineCap = kCGLineCapButt;
xAxis.axisLineStyle = lineStyle;
xAxis.majorTickLength = 10;
xAxis.orthogonalCoordinateDecimal = CPTDecimalFromDouble(yAxisStart);
xAxis.paddingBottom = 5;
xyAxisSet.delegate = self;
xAxis.delegate = self;
xAxis.labelOffset = 0;
xAxis.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
[plotSpace scaleToFitPlots:[graph allPlots]];
CPTMutablePlotRange *yRange = plotSpace.yRange.mutableCopy;
[yRange expandRangeByFactor:CPTDecimalFromDouble(1.3)];
plotSpace.yRange = yRange;
NSInteger xLength = CPTDecimalIntegerValue(plotSpace.xRange.length) + 1;
plotSpace.xRange = [CPTPlotRange
plotRangeWithLocation:CPTDecimalFromDouble(xAxisStart)
length:CPTDecimalFromDouble(xLength)] ;