我想添加多个x轴,我的代码如下:
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)barChart.axisSet;
/// Here I customize default x and y axis. And they are correctly visible
// Now create additional x axis
CPTXYAxis *bottomX = [[CPTXYAxis alloc]init];
bottomX.orthogonalCoordinateDecimal = CPTDecimalFromString(@"4");
CPTMutableLineStyle * lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.lineWidth = 3.0f;
lineStyle.lineColor = [CPTColor greenColor];
lineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:5.0f], [NSNumber numberWithFloat:5.0f], nil];
bottomX.axisLineStyle = lineStyle;
NSMutableArray * axes=[NSMutableArray arrayWithArray:axisSet.axes];
[axes addObject:bottomX];
axisSet.axes=axes;
默认的x,y轴是完美的,但附加的x轴(bottomX)没有显示任何位置。
答案 0 :(得分:4)
您需要在新轴上设置绘图空间:
bottomX.plotSpace = barChart.defaultPlotSpace;