I am having an issue with core plot which is causing me grief and having scoured the internet cannot find a solution. I fear it is a very simple oversight but for the life of me I cannot work out what it is.
Essentially when I set custom labels in core plot, only one of the labels appears at tick location zero, even though the relevant arrays are populated with the correct data like tick location and label.
I by-passed the custom label routine by manually entering in newLabels into the customLabels array and this worked, so I fear I am missing something basic in the routine somewhere.
NSUInteger labelLocation = 0;
NSMutableArray *customLabels = [[NSMutableArray alloc] initWithCapacity:[self.days count]];
for (NSNumber *tickLocation in self.customTickLocations)
{
CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText:[self.dateLabels objectAtIndex:labelLocation] textStyle:axisTextStyle];
newLabel.tickLocation = [tickLocation decimalValue];
int i = [tickLocation intValue];
newLabel.offset = 5.0f;
newLabel.rotation = M_PI/4;
[customLabels addObject:newLabel];
NSLog(@"Label is %@", [self.dateLabels objectAtIndex:labelLocation]);
labelLocation = labelLocation + 1;
NSLog(@"Tick Location is %i", i);
}
NSLog(@"Number of labels is %i", [customLabels count]);
axisSet.xAxis.axisLabels = [NSSet setWithArray:customLabels];
axisSet.xAxis.majorTickLocations = [NSSet setWithArray:self.customTickLocations];
NSLog(@"I have set customlabels");
This is my Log:
2012-09-11 10:39:23.725 SnoozeBaby[12000:c07] Label is 11 Sep
2012-09-11 10:39:23.725 SnoozeBaby[12000:c07] Tick Location is 0
2012-09-11 10:39:23.725 SnoozeBaby[12000:c07] Label is 10 Sep
2012-09-11 10:39:23.726 SnoozeBaby[12000:c07] Tick Location is 150
2012-09-11 10:39:23.726 SnoozeBaby[12000:c07] Number of labels is 2
2012-09-11 10:39:23.728 SnoozeBaby[12000:c07] I have set customlabels