views:

736

answers:

4

I am developing an iPhone app using Cocoa Touch and SQLite. I want to generate a graphical (chart) report. How can I generate a graphical chart report? Are there any tools for generation graphical report easily?

+1  A: 

I don't know of any pre-made charting components. You'd have to subclass UIView and write the Quartz2d code to draw whatever it was you are after.

U62
+1  A: 

Right now, your best option is to do what U62 suggests and draw your own custom charts via Quartz in a custom UIView's drawRect: method.

However, there is a rapidly evolving BSD-licensed open source framework called Core Plot (mailing list) which will be able to draw many types of plots and charts. This framework's UI classes are based on Core Animation CALayers in order to be cross-platform (support both Mac and iPhone with the same codebase). As I said, it's in its earliest stages, but the project has a number of contributors and seems to be coming along quickly.

Brad Larson
A: 

Another alternative would be to develop your charting code in Javascript using CSS/HTML graphics, and display that in a webView. You can use the webView's loadHTMLString to insert your charting code in the webview (rather than loading an external URL), and use stringByEvaluatingJavaScriptFromString to interact with it, send it params for the chart, etc.

This is a round-about solution and may not produce charts that look as slick as using native graphics, but there are a lot of Javascript/CSS charting solutions available freely on the web so this method might shortcut development time.

micco
A: 

Another alternative - haven't tried it myself but no obvious reason why it won't work:

Mobile Safari (and therefore UIWebView) supports SVG. You could create the SVG in memory and then pass it to

- (void)loadData:(NSData *)data 
        MIMEType:(NSString *)MIMEType 
textEncodingName:(NSString *)encodingName 
         baseURL:(NSURL *)baseURL

Remember to set the correct mime type.

Dan Bennett