我碰到的與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