
I have to draw a pie chart similar to this graph. I have to display data label with text in two lines as mentioned in the image (Actual Count and the percent value) I want to know whether this is possible or not using core plot. I am using the below delegate to to get either percent or the actual count, but not sure of how to get both values in that. Any help would be highly appreciated.
-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index {
if([plot isKindOfClass:[CPTPieChart class]]) {
static CPTMutableTextStyle *labelText = nil;
if (!labelText) {
labelText= [[CPTMutableTextStyle alloc] init];
labelText.color = [CPTColor blueColor];
}
NSDecimalNumber *portfolioSum = [NSDecimalNumber zero];
for (NSDecimalNumber *price in [[CPDStockPriceStore sharedInstance] dailyPortfolioPrices]) {
portfolioSum = [portfolioSum decimalNumberByAdding:price];
}
NSDecimalNumber *countValue = [[[CPDStockPriceStore sharedInstance] dailyPortfolioPrices] objectAtIndex:index];
NSString *labelValue = [NSString stringWithFormat:@"%@",countValue];
CPTTextLayer *textLayer = [[CPTTextLayer alloc]initWithText:labelValue];
return textLayer;
}
else {
return nil;
}
}