我在iOS應用程序中使用核心繪圖,並且想要格式化軸的步驟。我所得到的是0.5的步驟,我不知道還有什麼可以改變的。我剔地點應由5,10,15和20核心繪圖:刻度間隔
這裏是吸引我的軸代碼:
-(void) addAxis{
// Create grid line styles
CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
majorGridLineStyle.lineWidth = 1.0f;
majorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.75];
NSSet *majorTickLocations = [NSSet setWithObjects:[NSDecimalNumber zero],
[NSDecimalNumber numberWithUnsignedInteger:5],
[NSDecimalNumber numberWithUnsignedInteger:10],
[NSDecimalNumber numberWithUnsignedInteger:15],
[NSDecimalNumber numberWithUnsignedInteger:20],
nil];
// Create axes
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)self.graph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
{
x.labelingPolicy = CPTAxisLabelingPolicyLocationsProvided;
x.tickDirection = CPTSignNone;
x.majorTickLocations = majorTickLocations;
x.labelOffset = 6.0;
x.labelRotation = M_PI/2;
x.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(19.0f)];
x.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(30.0f)];
x.title = @"Jahre";
x.titleOffset = 35.0f;
x.titleLocation = CPTDecimalFromFloat(x.visibleRange.lengthDouble/2.0);
x.plotSpace = self.barPlotSpace;
}
CPTXYAxis *y = axisSet.yAxis;
{
y.labelingPolicy = CPTAxisLabelingPolicyLocationsProvided;
y.majorTickLocations = majorTickLocations;
y.minorTicksPerInterval = 0;
y.preferredNumberOfMajorTicks = 8;
y.majorGridLineStyle = majorGridLineStyle;
y.axisLineStyle = nil;
y.majorTickLineStyle = nil;
y.minorTickLineStyle = nil;
y.labelOffset = 10.0;
y.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(30.0f)];
y.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(18.5f)];
y.title = @"Sparbetrag";
y.titleOffset = 40.0f;
y.titleLocation = CPTDecimalFromFloat(y.visibleRange.lengthDouble/2.0);
y.plotSpace = barPlotSpace;
}
// Set axes
self.graph.axisSet.axes = [NSArray arrayWithObjects:x, y, nil];
}