开发者

How to draw a simple line dynamic graph on iPhone

How do I draw a simple line dynamic graph on the iPhone? The x-axis should show the profit by default and the y-axis should show the loss 开发者_运维知识库value. I'm trying the plot, but I am unsuccessful. Do you have any ideas or examples? Please help me. Thanks.


Core-plot is a good framework to do the graphs. Or draw manually using quartz2d


i have solved it. use a simple line graph calculations.


Create a custom view to handle your graphic. And in this view, do something like this (not tested, just written on the fly):

- (void)drawRect:(CGRect)rect;
{
    [super drawRect:rect];
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(ctx, 1.0, 0, 0.0, 1);
    CGContextMoveToPoint(ctx, 0, 0);
    for(NSInteger *i  in profits)
    {
         CGContextAddLineToPoint( ctx, 10, [i intValue]);
    }
    CGContextStrokePath(ctx);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜