1

我想添加多个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) 没有显示任何位置。

4

1 回答 1

4

您需要在新轴上设置绘图空间:

bottomX.plotSpace = barChart.defaultPlotSpace;
于 2012-04-11T22:21:41.170 回答