0
在我的图表中,majorGridLines对整个数字都能正常工作,但是当范围介于3.0和0.0之间时,10个或更多的majorTickLocations。 tick位置在正确的位置,IE大约每0.3,但主要的GridLines与Tick不在同一位置,它们只落在整个数字1.0,2.0,3.0等。我怎样才能让majorGridLines工作与不完整的数字,并与tickLocations水平?核心图Y轴majorgridline只能落在整数上?
代码如下:
NSMutableSet *yLabels = [NSMutableSet set];
NSMutableSet *yMajorLocations = [NSMutableSet set];
for (int i=-1; i<numYAxisLabels; i++) {
id jAsID = [NSNumber numberWithInt:(int)j];
int jAsInt = [jAsID integerValue];
CPTAxisLabel *label;
if(majorIncrement < 1)
label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%.1f", j] textStyle:y.labelTextStyle];
else
label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%d", jAsInt] textStyle:y.labelTextStyle];
NSDecimal location = CPTDecimalFromFloat(j);
label.tickLocation = location;
label.offset = -y.majorTickLength - y.labelOffset;
[yLabels addObject:label];
[yMajorLocations addObject:jAsID];
currTopYLabelLocation = j;
j += majorIncrement;
}
y.axisLabels = yLabels;
y.majorTickLocations = yMajorLocations;
谢谢Eric,就是这样!我的道歉,我认为情况并非如此,因为tickLocations出现的很好。 – Baconbeastnz 2013-02-25 01:48:49