• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple Graphs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Simple Graphs
      • From: "Jordan Krushen" <email@hidden>
    • Re: Simple Graphs
      • From: "Jordan Krushen" <email@hidden>
References: 
 >Music File information (From: Aalok <email@hidden>)
 >Re: Music File information (From: Julio Cesar Silva dos Santos <email@hidden>)
 >Simple Graphs (From: Neto <email@hidden>)

  • Prev by Date: ANN: StepTalk 0.12
  • Next by Date: Re: Simple Graphs
  • Previous by thread: Simple Graphs
  • Next by thread: Re: Simple Graphs
  • Index(es):
    • Date
    • Thread