user517491
user517491

Reputation:

Add additional x axes in core-plot

I want to add multiple x-axis, My code is as follows:

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;

The default x,y axes are perfect, but the additional x axis (bottomX) is not showing any where.

Upvotes: 1

Views: 666

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

You need to set the plot space on the new axis:

bottomX.plotSpace = barChart.defaultPlotSpace;

Upvotes: 4

Related Questions