2016-05-31 2 views

답변

0

나는

`NSMutableArray *monthLabelset = [[NSMutableArray alloc]init]; 
    NSMutableArray *monthsDataset = [[NSMutableArray alloc]init]; 
    NSArray *months = [[NSArray alloc]initWithObjects:@"jan",@"feb",@"mar",@"apr",@"may",@"jun",@"jul",@"aug",@"sep",@"oct",@"nov",@"dec", nil]; 

    for (int i = 0; i<months.count; i++) 
    { 
     CPTAxisLabel *monthsLabel = [[CPTAxisLabel alloc]initWithText:[months objectAtIndex:i] textStyle:xAxis.labelTextStyle]; 
     monthsLabel.tickLocation = [NSNumber numberWithInt:i]; 
     monthsLabel.offset  = 3.0; 
     NSString *month = [months objectAtIndex:i]; 
     if (monthsLabel) 
     { 
      if(i%2 == 0) 
      { 
       [monthLabelset addObject:monthsLabel]; 
       [monthsDataset addObject:month]; 
      } 

     } 


    } 

    NSMutableSet *monthLabels = [[NSMutableSet alloc]initWithArray:monthLabelset]; 
    NSMutableSet *monthsData = [[NSMutableSet alloc]initWithArray:monthsDataset]; 
    xAxis.labelingPolicy = CPTAxisLabelingPolicyNone; 
    xAxis.axisLabels = monthLabels; 
    xAxis.majorTickLocations = monthsData; 

     plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:[NSNumber numberWithInt:0] length:[NSNumber numberWithInt:11]]; 
     plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:[NSNumber numberWithInt:(yAxisMin)] length:[NSNumber numberWithInt:(yAxisMax - yAxisMin)]]; 
     [xAxis setMajorIntervalLength:[NSNumber numberWithInt:2]]; 
     [yAxis setMajorIntervalLength:[NSNumber numberWithInt:1]]; 
     [yAxis setLabelFormatter:axisFormatter]; 

     CPTMutablePlotRange *xRange = [plotSpace.xRange mutableCopy]; 
     CPTMutablePlotRange *yRange = [plotSpace.yRange mutableCopy]; 
     [xRange expandRangeByFactor:[NSNumber numberWithDouble:1.06]]; 
     [yRange expandRangeByFactor:[NSNumber numberWithDouble:1.06]]; 
     plotSpace.xRange = xRange; 
     plotSpace.yRange = yRange; 
` 

내가 코드를 아래에 추가 솔루션을 가지고

if(i%2 == 0) 
    { 
     [monthLabelset addObject:monthsLabel]; 
     [monthsDataset addObject:month]; 
    } 
관련 문제