我得到了一个标准线图的一系列点,如下所示:
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,我只想连接两个点来显示一条线。
谢谢。
编辑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属性。
发布于 2011-09-20 20:32:08
如果我们说的是用石英直接画线,就像这样.
// get current context
CGContextRef ct = UIGraphicsGetCurrentContext();
CGContextBeginPath(ct);
CGContextMoveToPoint(ct, startPointX, startPointY);
CGContextAddLineToPoint(ct, endPointX, endPointY);
CGContextStrokePath(ct);如果没有更多的信息,我真的帮不上忙。
https://stackoverflow.com/questions/7491168
复制相似问题