我碰到的与iOS和核心情节正确显示我的Y轴标签的一些问题...核心情节和显示ÿ标签
我会告诉你两种不同的情景我现在有,并希望有人可以帮助我得到正常工作其中之一......
好了,所以第一种方案: 代码:
// Configure y-axis
CPTAxis *y = axisSet.yAxis;
y.axisLineStyle = axisLineStyle;
y.majorGridLineStyle = customGridStyle;
y.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
y.labelTextStyle = axisTextStyle;
y.majorTickLineStyle = axisLineStyle;
y.majorTickLength = 0.0f;
y.minorTickLength = 0.0f;
y.tickDirection = CPTSignNegative;
NSInteger majorIncrement = [self findStep:(maxValue - minValue)/7];
CGFloat yMax = [self findMaximumValue:maxValue];
NSMutableSet *yLabels = [NSMutableSet set];
NSMutableSet *yMajorLocations = [NSMutableSet set];
int maxLocation = 0;
for (NSInteger j = 0; j <= yMax + majorIncrement; j += majorIncrement) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%i", j] textStyle:y.labelTextStyle];
NSDecimal location = CPTDecimalFromInteger(j);
label.tickLocation = location;
label.offset = 125;
if (label) {
[yLabels addObject:label];
}
[yMajorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:location]];
if (maxLocation < [[NSDecimalNumber decimalNumberWithDecimal:location] intValue]) {
maxLocation = [[NSDecimalNumber decimalNumberWithDecimal:location] intValue];
}
}
y.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0) length:CPTDecimalFromInteger(maxLocation)];
y.axisLabels = yLabels;
y.majorTickLocations = yMajorLocations;
现在这个代码的工作在一定程度上...查看我下面的截图:
在这里,我很想改变部分是小数......我想改变小数点的位置到现在显示.0 ...
场景(我真的很喜欢的那个) 为了节省阅读下面的代码的麻烦,我可以指出这里的大变化是:
y.labelingPolicy = CPTAxisLabelingPolicyNone;
代码:
// Configure y-axis
CPTAxis *y = axisSet.yAxis;
y.axisLineStyle = axisLineStyle;
y.majorGridLineStyle = customGridStyle;
y.labelingPolicy = CPTAxisLabelingPolicyNone;
y.labelTextStyle = axisTextStyle;
y.majorTickLineStyle = axisLineStyle;
y.majorTickLength = 0.0f;
y.minorTickLength = 0.0f;
y.tickDirection = CPTSignPositive;
NSInteger majorIncrement = [self findStep:(maxValue - minValue)/7];
CGFloat yMax = [self findMaximumValue:maxValue];
NSMutableSet *yLabels = [NSMutableSet set];
NSMutableSet *yMajorLocations = [NSMutableSet set];
int maxLocation = 0;
for (NSInteger j = 0; j <= yMax + majorIncrement; j += majorIncrement) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%i", j] textStyle:y.labelTextStyle];
NSDecimal location = CPTDecimalFromInteger(j);
label.tickLocation = location;
label.offset = -25;
if (label) {
[yLabels addObject:label];
}
[yMajorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:location]];
if (maxLocation < [[NSDecimalNumber decimalNumberWithDecimal:location] intValue]) {
maxLocation = [[NSDecimalNumber decimalNumberWithDecimal:location] intValue];
}
}
y.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0) length:CPTDecimalFromInteger(maxLocation)];
y.axisLabels = yLabels;
y.majorTickLocations = yMajorLocations;
x.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(0) length:CPTDecimalFromInteger(maxLocation)];
,情节出来为:
现在这里有很多Ÿ轴系失踪......
任何帮助将不胜感激!
谢谢,埃里克!我真的很想用无策略创建标签,在那里我可以更好地控制步骤等,但现在我使用了格式化labelFormatter的解决方案,直到我使其他部分更好地工作......谢谢! – user969043