Re: [newbie] Drawing a 2D graph
Re: [newbie] Drawing a 2D graph
- Subject: Re: [newbie] Drawing a 2D graph
- From: Brad <email@hidden>
- Date: Sat, 15 Nov 2003 17:51:30 -0700
On Nov 15, 2003, at 4:47 PM, Matt Crocker wrote:
>
Hi
>
>
Thanks to everyone who helped out with my NSMutableArray question of a
>
few hours ago. I have now used their suggestions to obtain a set of
>
data points held in arrays within my code. Now, I want to draw a
>
simple line graph made up from the x,y coordinates I have obtained
>
from the data file. I have been searching through the archives and it
>
all seems massively over-complicated for what I want to do. Setting up
>
OpenGL has me baffled (it is probably overkill for this), and trying
>
to implement a few examples using implementations of drawRect just to
>
draw *something* in by NSView has no effect.
>
>
The state of play so far is:
>
>
1. I have an NSView in my NIB file which is wired up to an outlet
>
called profileDisplay.
>
2. I have pairs of x,y coordinates.
>
3. I want to draw these as a nice, simple line within this NSView.
>
>
I have no idea how I apply the drawRect to my profileDisplay. Once
>
this is working, I'm sure I can work out how to use moveToPoint, etc
>
to draw my little line.
>
>
As usual, I'm sure it's simple, and it's me who's been stupid.
>
>
Thanks loads in advance.
>
What you need to do is make a subclass of NSView, say myView. Import
it into IB and change the NSView's class to myView in the Custom Class
Inspector. That'll give you your drawing area. Then in myView
override drawRect and put your drawing code into it.
Take a look at
http://cocoadevcentral.com/articles/000051.php and
http://cocoadevcentral.com/articles/000045.php. Both articles deal
with drawing in a custom view.
Brad
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.