我正在尝试使用带有 x 和 y 值的简单 excel csv 文件并将其放入 NSArray 中,以便我可以使用它来使用 core-plot 绘制散点图。我已经设置了代码来显示带有某些数据图的图表:
JACViewController.m
#import "JACViewController.h"
@implementation JACViewController
@synthesize scatterPlot;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSMutableArray *data = [NSMutableArray array];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(-10, 100)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(-8, 50)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(-6, 20)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(-4, 10)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(-2, 5)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(0, 0)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(2, 4)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(4, 16)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(6, 36)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(8, 64)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(10, 100)]];
self.scatterPlot = [[JACSimpleScatterPlot alloc] initWithHostingView:_graphHostingView andData:data];
[self.scatterPlot initialisePlot];
}
@end
但现在我想使用 excel 中的 CSV 文件并显示我从那里获得的数据。
Excel 文件如下所示:
a1= "数据 X" b1= "数据 Y" a2:a8=(1,2,3,4,5,6,7) b2:b8=(10,20,30,40,50,60,70)