Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks like you missed first and second slices. <code>numberOfRecordsForPlot</code> can return 4, but in <code>numberForPlot</code> some code returns <code>nil</code>.. I created a new Pie Chart with your values, and all works nice. See code below.</p> <p>You can also try to see data labels for every slice in the <code>-(CPLayer *)dataLabelForPlot:(CPPlot *)plot recordIndex:(NSUInteger)index</code> delegate method. If you really have 4 slices then 2 of them will placed at the same position. Code below is as well.</p> <p><img src="https://i.stack.imgur.com/xfg5q.png" alt="enter image description here"></p> <pre><code>-(void) viewDidLoad{ NSMutableArray *contentArray = [NSMutableArray arrayWithObjects:[NSNumber numberWithInt:9], [NSNumber numberWithInt:9], [NSNumber numberWithInt:63], [NSNumber numberWithInt:18], nil]; self.dataForChart = contentArray; // Add pie chart CPPieChart *piePlot = [[CPPieChart alloc] init]; piePlot.dataSource = self; piePlot.pieRadius = 100.0; piePlot.identifier = @"Pie Chart 1"; piePlot.startAngle = M_PI; piePlot.sliceDirection = CPPieDirectionClockwise; piePlot.delegate = self; [pieChart addPlot:piePlot]; [piePlot release]; } #pragma mark - #pragma mark Plot Data Source Methods -(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot{ return [self.dataForChart count]; } -(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { if ( index &gt;= [self.dataForChart count] ) return nil; if ( fieldEnum == CPPieChartFieldSliceWidth ) { return [self.dataForChart objectAtIndex:index]; } else { return [NSNumber numberWithInt:index]; } } -(CPLayer *)dataLabelForPlot:(CPPlot *)plot recordIndex:(NSUInteger)index { CPTextLayer *label = [[CPTextLayer alloc] initWithText:[NSString stringWithFormat:@"%lu", index]]; label.textStyle.color = [CPColor lightGrayColor]; return [label autorelease]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload