Objective c 核心图:X轴标签卷曲
我正在向我的应用程序添加散点图,我想在X轴标签上显示包含在数组cogsetUsed(即自行车cogset)中的项目。项目数量可以从8到11 我得到的是: 这是一段代码:Objective c 核心图:X轴标签卷曲,objective-c,ios,core-plot,xcode4.5,Objective C,Ios,Core Plot,Xcode4.5,我正在向我的应用程序添加散点图,我想在X轴标签上显示包含在数组cogsetUsed(即自行车cogset)中的项目。项目数量可以从8到11 我得到的是: 这是一段代码: CPTGraph *graph = self.hostView.hostedGraph; CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; CPTXYAxis *x = axisSet.xAxis; x.visibleRange = [CPTPlotRange p
CPTGraph *graph = self.hostView.hostedGraph;
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
x.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0) length:CPTDecimalFromInteger(12)];
x.labelingPolicy = CPTAxisLabelingPolicyNone;
x.labelTextStyle = axisTextStyle;
x.majorTickLineStyle = axisLineStyle;
x.majorTickLength =4.0f;
x.tickDirection =CPTSignNegative;
CGFloat recordCount = [cogsetUsed count];
NSMutableSet *xLabels =[NSMutableSet setWithCapacity:recordCount];
NSMutableSet *xLocations = [NSMutableSet setWithCapacity:recordCount];
NSInteger i =0;
for (NSString *sprocket in cogsetUsed) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:sprocket textStyle:x.labelTextStyle];
CGFloat location = i++;
label.tickLocation = CPTDecimalFromCGFloat(location);
label.offset =x.majorTickLength;
if (label) {
[xLabels addObject:label];
[xLocations addObject:[NSNumber numberWithFloat:location]];
}
}
x.axisLabels = xLabels;
x.majorTickLocations = xLocations;
谢谢你的帮助 核心图不能防止标签之间的冲突。没有要求每个记号都要贴上标签。因为您正在创建自定义轴标签,所以不要标记每个记号位置。看起来你可以每三分之一或四分之一标记一次,以获得良好的外观