Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 核心图:X轴标签卷曲_Objective C_Ios_Core Plot_Xcode4.5 - Fatal编程技术网

Objective c 核心图:X轴标签卷曲

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

我正在向我的应用程序添加散点图,我想在X轴标签上显示包含在数组cogsetUsed(即自行车cogset)中的项目。项目数量可以从8到11

我得到的是:

这是一段代码:

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;

谢谢你的帮助

核心图不能防止标签之间的冲突。没有要求每个记号都要贴上标签。因为您正在创建自定义轴标签,所以不要标记每个记号位置。看起来你可以每三分之一或四分之一标记一次,以获得良好的外观