- (void)viewDidLoad
{
graph = [[CPTXYGraph alloc] initWithFrame: self.view.bounds];
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.hostedGraph = graph;
CPTPieChart *pieChart = [[CPTPieChart alloc] init];
pieChart.dataSource = self;
pieChart.pieRadius = 100.0;
pieChart.identifier = @"PieChart1";
pieChart.startAngle = M_PI_4;
pieChart.sliceDirection = CPTPieDirectionCounterClockwise;
self.pieData= [NSMutableArray arrayWithObjects:[NSNumber numberWithDouble:90.0],
[NSNumber numberWithDouble:20.0],
[NSNumber numberWithDouble:30.0],
[NSNumber numberWithDouble:40.0],
[NSNumber numberWithDouble:50.0],
[NSNumber numberWithDouble:60.0], nil];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[graph applyTheme:theme];
[graph addPlot:pieChart];
[pieChart release];
}
I found this code on the net.This Code is working fine but am getting two warnings at
pieChart.dataSource = self;
It says.
warning: class ‘SOTC_CorePlotExampleViewController’ does not
implement the ‘CPTPlotDataSource’ protocolwarning: Semantic Issue: Assigning to ‘id’ from
incompatible type ‘SOTC_CorePlotExampleViewController *’
add
<CPTPlotDataSource>to the end of your custom view controller’s declaration in your @interface (.h) file:(change YourViewController in my example to whatever the name of your view controller is)