我必须绘制一个类似于此图的饼图。我必须在图像中提到的两行中显示带有文本的数据标签(实际计数和百分比值)我想知道这是否可能使用核心图。我正在使用下面的委托来获取百分比或实际计数,但不确定如何获取这两个值。任何帮助将不胜感激。
-(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;
}
}