Thomas Clayson
Thomas Clayson

Reputation: 29925

Add second plot space/axis to core-plot

Here is my code:

CPTXYPlotSpace *barGraphPlotSpace = [[CPTXYPlotSpace alloc] init];
barGraphPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0) length:CPDecimalFromFloat(100.0)];

CPTXYAxis *rightY = [[CPTXYAxis alloc] init];
rightY.coordinate = CPTCoordinateY;
rightY.orthogonalCoordinateDecimal = CPTDecimalFromFloat(oneDay*7);

rightY.plotSpace = barGraphPlotSpace;

[graph addPlotSpace:barGraphPlotSpace];

This doesn't add another axis to my graph though.

What I'm trying to do is get a second y axis which will go from 0-100 (percent). To do this I'm creating a new plot space and a new y axis adding the new plot space to the y axis and adding the plot space to the graph.

What am I doing wrong?

Thank you.

Upvotes: 3

Views: 2120

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

You need to add the new axis to the graph:

NSMutableArray *newAxes = [graph.axisSet.axes mutableCopy];
[newAxes addObject:rightY];
graph.axisSet.axes = newAxes;
[newAxes release];

Upvotes: 7

Related Questions