I want to create a graph in my ipad which takes 3 to 4 inputs and then creates graph i have found solution using pie chart but i want simple graph with x-axis values and y-axis values.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to use a complex framework with lot of features, checkout : Core Plot.
In case you want simple Graph paper layout,
You will need to subclass UIView and override drawRect and make draw dotted lines using loops.
depending what how many vertical and horizontal lines you can accomodate.
Also for drawing the graph, pass an NSArray to the GraphView containing CGPoints wrapped by NSValue.
loop through the points and convert them to physical coordinates of the View.
for this you will need to keep track of how many screen pixels does each x and y unit represent and then little bit of math will give you screen pixels of the GraphView.
Just join the Points by straight lines using Core Graphics functions.
CGContextMoveToPoint and CGContextAddlineToPoint.
You will need to use different CGPaths to draw different components of the view like Graph lines, axis lines and the graph itself.
But if you really need more complex tasks go for Core-Plot.
Checkout Core-Plot examples at :
http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application