views:

222

answers:

2

I developed graph using NSObject class and using CGContext method. The following code displaying dynamically in X and Y-axis intervals,

    CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);
    CGContextSetLineWidth(ctx, 2.0);
    CGContextMoveToPoint(ctx, 30.0, 200.0);
    CGContextAddLineToPoint(ctx, 30.0, 440.0);
    for(float y = 400.0; y >= 200.0; y-=30)
       {   
           CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);   
           CGContextMoveToPoint(ctx, 28, y);
           CGContextAddLineToPoint(ctx, 32, y);
           CGContextStrokePath(ctx);
           //CGContextClosePath(ctx);  
        }

    CGContextMoveToPoint(ctx, 10, 420.0);       
    CGContextAddLineToPoint(ctx, 320, 420.0);
    //CGContextAddLineToPoint(ctx, 320.0, 420.0);
    //CGContextStrokePath(ctx);
    for(float x = 60.0; x <= 260.0; x+=30)
       {   
           CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);   
           CGContextMoveToPoint(ctx, x, 418.0);
           CGContextAddLineToPoint(ctx, x, 422.0);
           CGContextStrokePath(ctx);
           CGContextClosePath(ctx);  
        }

I want to write the dynamic text on the X and Y-axis lines near the intervals (like X-axis is denoting number of days per week and Y-axis denoting something per someting)? Thanks.

+5  A: 

You might want to look at the Core Plot framework.

Steve Harrison
hi Steve Harrison,Their is an appliaction .dmg file. The google is not providing source code of your given link (Core plot).I want either source code ya tutorial on it.
RRB
@Rajendra Bhole: If you click on the "Source" tab at the top of the linked page, you will be taken to a page where you can browse the source code of the project. It also has instructions on how to download the latest build of the framework, including several sample iPhone applications, using Mercurial. For more, see this page: http://code.google.com/p/core-plot/wiki/UsingMercurial and this one: http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications
Brad Larson
+1  A: 

The link Steve provided above has source code. Under the tab that says "Source"

http://code.google.com/p/core-plot/source/browse/

Khat
Kat,The above code is written using Core Plot framework. But i doesn't want that.
RRB
Why not? Looks like a great way to start.
zoul
zoul,i didn't get your comment.Please explain what you trying to say.
RRB
@Rajendra Bhole: What he means to ask is: what problems do you have with the Core Plot framework? Why write your own graphing implementation when one already exists? Unless there's something that the framework does not handle properly, it will take you much longer to write your own graphs than to just integrate this framework within your own projects.
Brad Larson
Brad Larson, thanks for given me brief idea, i now i develop the edited code given in the question.Shall it work properly when i developing dynamic graph weekly and monthly verses hours and minutes?
RRB
@Rajendra Bhole: Don't completely change your question after you've first asked it. People won't notice it has changed, and the answers now become incoherent. The new code is unrelated to your previous question about how to draw a graph. Also, we've already solved this problem in Core Plot, so why reinvent the wheel?
Brad Larson