Objective c 如何使用core plot为条形图设置新的绘图数据?
我不熟悉objective-c和xcode。如果有人能指出如何使用core plot为条形图设置新的绘图数据,那将是非常感谢的。 我需要设置如下数据: y轴和x轴:as(10,1)、(5,2)、(20,3)、(15,4) 输出应如下所示: --------------------- 30 25 20 # 15 # # 10 # # # 5 # # # # 1 2 3 4 --------------------- --------------------- 30 25 20 # 15 # # 10 # # # 5 # # # # 1 2 3 4 --------------------- 如果有人能给我提供.m和.h文件就太好了 提前谢谢Objective c 如何使用core plot为条形图设置新的绘图数据?,objective-c,xcode,core-plot,Objective C,Xcode,Core Plot,我不熟悉objective-c和xcode。如果有人能指出如何使用core plot为条形图设置新的绘图数据,那将是非常感谢的。 我需要设置如下数据: y轴和x轴:as(10,1)、(5,2)、(20,3)、(15,4) 输出应如下所示: --------------------- 30 25 20 # 15 # # 10 # # # 5 # # # # 1 2 3 4 --------------------- ---------------------
Joshua查看核心绘图目录中示例文件夹中的程序。所有三个CPTestApp程序(Mac、iPhone和iPad)都有条形图。函数号orplot用于定义要绘制的数据:
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSNumber *num = nil;
if ( [plot isKindOfClass:[CPBarPlot class]] ) {
switch ( fieldEnum ) {
case CPBarPlotFieldBarLocation:
num = (NSNumber *)[NSNumber numberWithFloat:[[*yourArray* objectAtIndex:index] floatValue]];
break;
case CPBarPlotFieldBarLength:
num = (NSNumber *)[NSNumber numberWithFloat:[[*yourOtherArray* objectAtIndex:index] floatValue]];
break;
}
}
return num;
}
您只需在数组中插入数据