hi this is the code
.h file
@interface PieChart : UIViewController
<CPTPieChartDataSource,CPTPlotSpaceDelegate,
CPTPlotDataSource>
{
IBOutlet CPTGraphHostingView *pieChartGraphView;
CPTXYGraph *pieChartGraph;
NSMutableArray *chartData;
NSMutableArray *description;
}
.m file
- (void)viewDidLoad
{
[super viewDidLoad];
chartData=[[NSMutableArray alloc]init];
pieChartGraph=[[CPTXYGraph alloc]initWithFrame:[pieChartGraphView
bounds]];
pieChartGraphView.hostedGraph=pieChartGraph;
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[pieChartGraph applyTheme:theme];
pieChartGraph.paddingLeft = 20.0;
pieChartGraph.paddingTop = 20.0;
pieChartGraph.paddingRight = 20.0;
pieChartGraph.paddingBottom = 20.0;
pieChartGraph.axisSet = nil;
CPTPieChart *piePlot = [[CPTPieChart alloc] init];
piePlot.dataSource = self;
piePlot.delegate=self;
piePlot.pieRadius = 100.0;
piePlot.identifier = @"Pie Chart 1";
piePlot.startAngle = M_PI_4;
piePlot.sliceDirection = CPTPieDirectionCounterClockwise;
[pieChartGraph addPlot:piePlot];
[piePlot release];
CPTLegend *theLegend = [CPTLegend legendWithGraph:pieChartGraph];
theLegend.numberOfColumns = 1;
theLegend.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
theLegend.borderLineStyle = [CPTLineStyle lineStyle];
theLegend.cornerRadius = 5.0;
pieChartGraph.legend = theLegend;
pieChartGraph.legendAnchor = CPTRectAnchorBottom;//
CPTRectAnchorRight;
pieChartGraph.legendDisplacement = CGPointMake(-16 -10, 0.0);
NSMutableArray *contentArray = [NSMutableArray arrayWithObjects:
[NSNumber numberWithDouble:20.0], [NSNumber numberWithDouble:30.0],
[NSNumber numberWithDouble:60.0], nil];
self.chartData = contentArray;
}
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{
return [self.chartData count];
}
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index
{
if ( index >= [self.chartData count] ) return nil;
if ( fieldEnum == CPTPieChartFieldSliceWidth ) {
return [self.chartData objectAtIndex:index];
}
else {
return [NSNumber numberWithInt:index];
}
}
-(NSString *)legendTitleForPieChart:(CPTPieChart *)pieChart
recordIndex:(NSUInteger)index
{
return [NSString stringWithFormat:@"Pie Slice %u", index];
}
-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:
(NSUInteger)index
{
static CPTMutableTextStyle *whiteText = nil;
if ( !whiteText ) {
whiteText = [[CPTMutableTextStyle alloc] init];
whiteText.color = [CPTColor whiteColor];
}
CPTTextLayer *newLayer = [[[CPTTextLayer alloc] initWithText:
[NSString stringWithFormat:@"%3.0f", [[chartData objectAtIndex:index]
floatValue]] style:whiteText] autorelease];
return newLayer;
}
-(IBAction)dismiss{
[self.parentViewController
dismissModalViewControllerAnimated:YES];
}
Hopefully u can point out where m goin wrong
thnsk again :)