Re: Simple Graphs
Re: Simple Graphs
- Subject: Re: Simple Graphs
- From: Scott Ellsworth <email@hidden>
- Date: Tue, 30 May 2006 23:16:30 -0700
On May 30, 2006, at 9:00 PM, Neto wrote:
I'm a beginner in XCode and I need to add simple bar graphs to my
application, if possible, bind them to NSTextFields.
Is there a straight forward method to do this?
There are a couple of good ways to go here.
Apple provides a level indicator, much like the star rating dealy in
iTunes. Check out <http://developer.apple.com/documentation/Cocoa/
Reference/ApplicationKit/Classes/NSLevelIndicator_Class/index.html#//
apple_ref/doc/uid/TP40004058>. If this would work for you, then you
are home free. Just drop one on the window in IB, and ctrl-drag to
bind it to the text field.
Assuming that the level indicator is not appropriate for your app,
you will need to make your own custom NSView subclass.
I would check out the cocoadev wiki at <http://cocoadev.com/>, and I
would Google for NSView, drawRect, and other likely search terms.
Once you have created your NSView subclass, you can connect the
NSTextField to your custom subclass very much like you would have
hooked up the NSLevelIndicator. Most Cocoa books describe the nuts
and bolts of connecting up your views, and exposing IBOutlets for the
things you want to tweedle in code. Check out Hillegass or Anguish/
Buck/Yacktman.
If you are willing to target 10.3 and higher, you can create your
NSView subclass, then bind it to appropriate data using Cocoa
Bindings. (Check the Apple docs for same.) This often has less code
than a solution using standard IBOutlets, but each has their place.
I did create an IWBarGraphView for the Lake Forest Cocoa-heads demo
project, NavComCocoa, which lurks on sourceforge. My bar graph was a
history list of many values, drawn as bars in a standard graph, so I
am not sure it would be of use. Still, it does have several NSView
subclasses, so it might be of interest. <http://svn.sourceforge.net/
viewcvs.py/cocoaheads/NavComCocoa/>
Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden