Reputation: 4111
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:
I could acheive this by switch(index)
, but why its not working this way?
Any Suggestion?
Upvotes: 0
Views: 275
Reputation: 27381
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:
Index RGB Color ------------------------------------------ 0 (1.0, 0.0, 0.0) Red 1 (0.0, 1.0, 0.0) Green 2 (0.0, 0.0, 1.0) Blue 3 (1.0, 1.0, 0.0) Yellow 4 (0.25, 0.5, 0.25) Dark green 5 (1.0, 0.0, 1.0) Magenta 6 (0.5, 0.5, 0.5) Gray 7 (0.25, 0.5, 0.0) Medium green 8 (0.25, 0.25, 0.25) Dark gray 9 (0.0, 1.0, 1.0) Cyan
Upvotes: 2