我是新手。我有一个名为NSObject
的{{1}}类,并在接口文件中声明了3个属性
在 dailyPortfolioPrices.h
中dailyPortfolioPrices
在 dailyPortfolioPrices.m 文件
中我合成了上面声明的属性。我创建了一个名为@interface dailyPortfolioPrices : NSObject
@property (nonatomic, weak) NSDecimalNumber *num1;
@property (nonatomic, weak) NSDecimalNumber *num2;
@property (nonatomic, weak) NSDecimalNumber *num3;
的{{1}}类,用于显示UIViewController
。
在PageContentViewController.m 文件' s PageContentViewController
我宣布了graph
的值
voidDidAppear
并将编码作为
![在此输入图片说明] [2]
用于计算百分比值
dailyPortfolioPrices
用于设置显示标签
dailyPortfolioPrices *dailyPortfolioPrices1 = [dailyPortfolioPrices new];
dailyPortfolioPrices1.num1 = @"586.13";
dailyPortfolioPrices1.num2 = @"606.53";
dailyPortfolioPrices1.num3 = @"32.03";
dailyPortfolioPrices *dailyPortfolioPrices2 = [dailyPortfolioPrices new];
dailyPortfolioPrices2.num1 = @"426.13";
dailyPortfolioPrices2.num2 = @"506.53";
dailyPortfolioPrices2.num3 = @"22.03";
dailyPortfolio = [NSArray arrayWithObjects: dailyPortfolioPrices1, dailyPortfolioPrices2, nil];
创建并返回带有标签文字的图层
NSDecimalNumber *price = [dailyPortfolio objectAtIndex:index];
NSDecimalNumber *percent = [price decimalNumberByDividingBy:portfolioSum];
但我的图表中没有显示任何数据。任何人都可以告诉我哪里弄错了。我想使用NSString *labelValue = [NSString stringWithFormat:@"$%0.2f USD (%0.1f %%)", [price floatValue], ([percent floatValue] * 100.0f)];
return [[CPTTextLayer alloc] initWithText:labelValue style:labelText]; }
-(NSString *)legendTitleForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index {
if (index < [[[CPDStockPriceStore sharedInstance] tickerSymbols] count]) {
return [[[CPDStockPriceStore sharedInstance] tickerSymbols] objectAtIndex:index];
}
return @"N/A";
}
中显示pie chart
提前感谢您的帮助