Am trying out a simple Pie Chart with Core Plot in an iPhone App. I want to plot a value, which is the percentage of CPU used. In the method 'numberForPlot', here is what I have written
-(NSNumber *) numberForPlot:(CPTPlot *)plot
field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index {
Health_Cpu *healthData = (Health_Cpu *) [dictHealth objectForKey:[self.arrayHealthKeys objectAtIndex:0]];
if (CPTPieChartFieldSliceWidth == fieldEnum) {
return [NSNumber numberWithFloat:healthData.cpuUsage]; // In Percentage
}
}
How do I tell Core Plot that this is a percentage value (i.e. if the value is 25.0, then it has to plot it as 25% i.e. color 1/4th of the pie chart)? Now, it is taking it as an absolute number. So what I have done is to return two values from numberForPlot, one being the value, and the other being (100-value).