首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >核心情节:制造麻烦线

核心情节:制造麻烦线
EN

Stack Overflow用户
提问于 2011-09-20 20:08:31
回答 1查看 376关注 0票数 0

我得到了一个标准线图的一系列点,如下所示:

代码语言:javascript
复制
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

下面是我如何设置图表:

代码语言:javascript
复制
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属性。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-20 20:32:08

如果我们说的是用石英直接画线,就像这样.

代码语言:javascript
复制
// get current context
CGContextRef ct = UIGraphicsGetCurrentContext();

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

如果没有更多的信息,我真的帮不上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7491168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档