maddy
maddy

Reputation: 4111

defaultPieSliceColorForINdex:index not returning proper color value: coreplot

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:
see image

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

Answers (1)

Eric Skroch
Eric Skroch

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

Related Questions