iphone, using an array to define in core-plot range

我们两清 提交于 2019-11-29 13:08:13

I finally found the solution using custom label:

            NSArray *customTickLocations = [NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:0],
                                                                     [NSDecimalNumber numberWithInt:5],
                                                                     [NSDecimalNumber numberWithInt:10],
                                                                     [NSDecimalNumber numberWithInt:15],
                                                                     [NSDecimalNumber numberWithInt:20],
                                                                     [NSDecimalNumber numberWithInt:25],
                                                                     [NSDecimalNumber numberWithInt:30],
                                                                     [NSDecimalNumber numberWithInt:35],                                                
                                                                     [NSDecimalNumber numberWithInt:40],                                                
                                                                     nil];
            NSArray *xAxisLabels = [NSArray arrayWithObjects:@"15",@"18",@"21",@"0",@"3",@"6",@"9",@"12",@"15",nil];

            NSUInteger labelLocation = 0;
            NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
            for (NSNumber *tickLocation in customTickLocations) {
                CPAxisLabel *newLabel = [[CPAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:labelLocation++] textStyle:axisSet.xAxis.labelTextStyle];
                newLabel.tickLocation = [tickLocation decimalValue];
                newLabel.offset = axisSet.xAxis.labelOffset + axisSet.xAxis.majorTickLength;
                [customLabels addObject:newLabel];
                [newLabel release];
            }

            axisSet.xAxis.axisLabels =  [NSSet setWithArray:customLabels];

Still have some thing to clarify but this is surely the way to go :) Luc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!