Reputation: 4409
I am working on core-plot. I want to make the graph which drawn in the screen need to be centered. when the application get loaded its showing from the bottom the graph. I want to make the entire view visible from center has shown in below figure.
@Thanks in advance
Upvotes: 0
Views: 313
Reputation: 2545
// Just set the xRange and YRange with initial offset:
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
/* Range which is visible on screen */
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(offset)
length:CPTDecimalFromFloat(X_LENGTH)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(offset_Y)
length:CPTDecimalFromFloat(Y_LENGTH)];
/* Total Range which is visible on screen and can be scrolled up to */
CPTPlotRange *globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0) length:CPTDecimalFromDouble(Y_LENGTH)];
plotSpace.globalYRange = globalYRange;
CPTPlotRange *globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0) length:CPTDecimalFromDouble(xRange)];
plotSpace.globalXRange = globalXRange;
/* To constraint X and Y axis */
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
axisSet.xAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:55.0];
axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
Upvotes: 1