2011-09-20 64 views
0

我有一个点的数组的标准线图如下所示:睿情节:捣乱线

Array = [NSArray arrayWithObjects: 
       [NSArray arrayWithObjects: [NSNumber numberWithInt: 10], [NSNumber numberWithInt: 20], nil], 
       [NSArray arrayWithObjects: [NSNumber numberWithInt: 30], [NSNumber numberWithInt: 40], nil], 
       nil]; 

的点显示在图形显示效果细腻,但我有麻烦找出如何连接这两点形成一条线。我可以在网上找到的所有示例处理绘制函数的路径,例如f(x)= 1/x。我只是想连接两点来显示一条线。

谢谢。


EDIT 1

这里是我设置的图形:

graph = [[CPTXYGraph alloc] init]; 
    CPTTheme *theme = [CPTTheme themeNamed:kCPTStocksTheme]; 
    [graph applyTheme:theme]; 
    graph.frame = self.view.bounds; 
    graph.paddingRight = 4.0f; 
    graph.paddingLeft = 4.0f; 
    graph.plotAreaFrame.masksToBorder = NO; 
    graph.plotAreaFrame.cornerRadius = 0.0f; 
    CPTMutableLineStyle *borderLineStyle = [CPTMutableLineStyle lineStyle]; 
    borderLineStyle.lineColor = [CPTColor whiteColor]; 
    borderLineStyle.lineWidth = 0.01f; 
    graph.plotAreaFrame.borderLineStyle = borderLineStyle; 
    self.graphHost.hostedGraph = graph; 

编辑2

要任何具有类似的问题,该您正在寻找的解决方案是dataLineStyle属性。

+0

您确实没有发布足够的代码以提供帮助。但是,您可能需要遵循以下教程:http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application – Perception

+0

您应该在初始化图形视图并设置它的位置包含代码属性。 Core Plot自己绘制线条,它不是你应该明确必须做的事情。 – Perception

回答

0

如果我们谈论的石英,像这样直接画线......

// get current context 
CGContextRef ct = UIGraphicsGetCurrentContext(); 

CGContextBeginPath(ct); 
CGContextMoveToPoint(ct, startPointX, startPointY); 
CGContextAddLineToPoint(ct, endPointX, endPointY); 
CGContextStrokePath(ct); 

没有更多的信息,我真的不能帮助。

+0

谢谢你的回复。不过,我希望通过Core-Plot来做到这一点。我基本上已经设置了一个基本的图表,并且这两点通常是绘制的。我很难搞清楚如何在Core-Plot中绘制线条。再次感谢。 –

+0

好吧,对不起 - 我从不使用Core-Plot。至少如果你从头开始编写代码,你就会知道如何画线! – Simon