0
我加入散点图到我的应用程序和我要显示在X轴上标签包含在数组中,cogsetUsed(即,一种自行车后变速盘)的项目。项目数可以从8到11核心剧情:X轴标签蜷缩
我得到的是以下几点:
这是一段代码:
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;
感谢您的帮助!