I am trying to use below delegate method to draw data label
-(CPTLayer *) dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index
{
CPTTextLayer *label = [[CPTTextLayer alloc] initWithText:
[NSString stringWithFormat:@"%u", index]];
CPTMutableTextStyle *textStyle = [label.textStyle mutableCopy];
textStyle.color = [CPTPieChart defaultPieSliceColorForIndex:index];
label.textStyle=textStyle;
return label;
}
the output I am getting is something like this:

so you can see the differences:
- slice 0 data label is of color red but should be yellow.
- slice 3 data label is of color yellow but should be magenta.
I could acheive this by switch(index), but why its not working this way?
Any Suggestion?
The labels are the correct colors—it’s the pie slices that don’t match the default colors. What values do the other datasource methods return?
The default colors are: