我有一个标准线图的点数组,如下所示:
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 属性。
答案 0 :(得分:0)
如果我们在谈论直接在Quartz中绘制线条,就像这样......
// get current context
CGContextRef ct = UIGraphicsGetCurrentContext();
CGContextBeginPath(ct);
CGContextMoveToPoint(ct, startPointX, startPointY);
CGContextAddLineToPoint(ct, endPointX, endPointY);
CGContextStrokePath(ct);
没有更多信息,我无法提供帮助。