사용자 정의 레이블을 사용하고 있으며 x 축 레이블이 다른 x 축 레이블에 부과 될 때 문제가 발생하며 사용자가 축소 할 때 해당 레이블을 숨기는 방법을 찾을 수 없습니다 (실시간).
아래의 프린트 스크린 참조 : "August 2012"레이블을 숨기고 싶습니다.
어떻게하면됩니까? 코드 아래에 다음코어 플롯 : 축 레이블이 서로 부과합니다
내가 사용하고 :
CPTXYAxis *x = axisSet.xAxis;
x.orthogonalCoordinateDecimal = CPTDecimalFromInteger(0);
x.majorIntervalLength = CPTDecimalFromInteger(150);
x.minorTicksPerInterval = 5;
x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0f];
x.labelingPolicy=CPTAxisLabelingPolicyNone;
NSUInteger labelLocation = 0;
NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[objects count]];
NSMutableSet *xMajorLocations = [NSMutableSet setWithCapacity:[objects count]];
for (NSInteger i = 0; i < [objects count]; i++) {
NSManagedObject *theLine = [objects objectAtIndex:i];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *sPeriodText = @"";
[dateFormatter setDateFormat:@"MMMM yyyy"];
sPeriodText = [dateFormatter stringFromDate:[theLine valueForKey:@"period_start"]];
CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText:sPeriodText textStyle:labelTextStyle];
newLabel.tickLocation = CPTDecimalFromInteger(labelLocation++);
newLabel.offset = x.labelOffset + x.majorTickLength;
[customLabels addObject:newLabel];
[xMajorLocations addObject:[NSNumber numberWithFloat:labelLocation-1]];
}
x.axisLabels = [NSSet setWithArray:customLabels];
x.majorTickLocations = xMajorLocations;
감사합니다!
P. CPTAxis의 labelExclusionRanges를 사용하려했지만 사용자 정의 레이블에서 작동하지 않았습니다.
이 솔루션은 레이블이 라인 노드와 일치하지 않는다는 점에 유의하고 싶습니다. 그래서 사용자 정의 라벨을 사용해야 할 필요가 있다고 생각합니다. – AlexeyVMP