Went looking around today for a way to generate charts/graphs in my Rails apps. Wow are there a lot of choices.
The executive summary is that I'm going to use the first Open Flash Chart plugin listed. I'm adding charts mainly for the "wow, neat" effect and the Flash charts max out that aspect. It seems like I might be able to work around the problems with printing. My second choice would probably be the ProtoChart Javascript library.
Plugins that generate images and/or SVG files:
Gruff
Scruffy
There are a couple of problems with these. Both use the RMagick library to generate images. RMagick is a Ruby wrapper around ImageMagick. So you're stuck with installing native dependencies (ImageMagick and all its dependencies) outside of Rails/Gems. And because you're providing the chart as a separate file you have to deal with sending the client a URL for the chart that comes back to your controller to generate the chart. There are probably neat Rails ways to handle that cleanly, but neither plugin seems to offer any best practices in their docs. I've also heard rumors that the RMagick/ImageMagick combo leaks memory like a sieve, but can't confirm that.
Plugins that use the Google Chart API:
Googlecharts
gchartrb
Google Charts on Rails
These all leave you dependent on connectivity and latency to Google.
Plugins that generate graphs using CSS/HTML:
css_graphs
There's only so much you can do in pure CSS/HTML, so this approach is fairly limited. If your needs are confined to basic bar charts this is a minimal-headache approach.
JavaScript libraries, particularly ones that work with Prototype since it is included with Rails:
Plotr
Flotr
ProtoChart
These are all pure JavaScript, so you're stuck dinking around in that instead of Ruby. There's a Rails wrapper for Plotr:
Chartr
Development of the JavaScript libraries and the Ruby library all seems largely stalled.
Plugins that generate Flash charts:
Wrappers for Open Flash Chart:
Open Flash Chart II Plugin for Ruby on Rails
Open Flash Chart Lazy
OFC2 4 Rails
These flash charts are the most visually interesting, as they are often animated and interactive, doing various cute (and maybe useful) things on mouse-over, etc. However, they leave you dependent on the client supporting/enabling Flash. It is also difficult/impossible to print the chart. You might also have the same issues as the image/SVG charts of having to generate a unique URL for the chart, although the author of the first plugin listed has a blog post that shows how to handle that in a very clean, Rails-like fashion.
Wrapper for XML/SWF:
ZiYa
Wrapper for amCharts:
Ambling
XML/SWF and amCharts are both demoware so I did not pursue these options.
Tuesday, January 06, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment