views:

663

answers:

9

I need to display some charts/graphs based upon user inputs on my web aplication built using Ruby on Rails. Are there any charting libraries out there that I could use with ROR for displaying simple bar, line and pie graphs?

+4  A: 

There is a nice gem called

gruff

for graphs in ruby. You'll need the fabulous imagemagick and rmagick library. Since installation of the latter two is not really trivial (but not difficult, either), there's a installation FAQ for that.

Looks something like this:

alt text

More examples of this library: http://geoffreygrosenbach.com/projects/show/5

The MYYN
A: 

Gruff is one.

Rickard
+1  A: 

Or cloudsource the charts via google - here's the gem for that: googlecharts.rubyforge.org

Example:

# console
$ ruby script/plugin install git://github.com/mattetti/googlecharts.git

# view
<img src="<%=GoogleChart.pie(['1997',10],['1998',70],['1999',20]).to_url%>">
The MYYN
A: 

There is another gem called scruffy that does not need rmagick & imagemagick/graphicsmagick if you want to generate only svg.

Here is the project page http://scruffy.rubyforge.org that has quite a few examples

nas
A: 

For small graphs, there is Sparklines

Justin Love
A: 

Yui chart from Yahoo it works also offline. There is a ruby plugin for it, I didn't know the name of it, sorry.

gustavgans
+2  A: 

Open Flash Chart 2 is very nice and pretty easy. You get more dynamic features (tooltips, onclick, hover, ...): looks nice :)

In this related question a few more very interesting alternatives are mentioned. Of which i find the most interesting (i am not allowed to use hyperlinks -so use google :)

  • flot, a jQuery based graphing library, with a rails plugin flotilla. Especially if you are already using jQuery in your Rails app, like i am.
  • raphael, which looks very interesting, and also has a smaller brother gRaphael, especially for graphs/charts. A pure javascript, alas without any plugin for the moment. But that should not be too hard.

These are both javascript libraries, offering the same kind of visual appearance and interactive as the flash alternative, without the flash, which is imho a big advantage. Aside of which it even seems there are more interactive options/possibilities than the open flash chart can offer. I am going to check these out :)

I am not allowed to show more than 1 url, so Google is your friend :)

Hope this helps :)

nathanvda
+1  A: 

In addition to the aptly named googlecharts gem mentioned above there are two more that use the Google Charts API, gchartb and ruby-googlechart.

For the very awesome protovis javascript charting library, looks like someone has started a rails plugin called protovis on rails, but it still looks rough and hasn't been touched in a while.

philoye
A: 

Down with flash and imagemagick.

Try Highcharts with the lazy high charts plugin for ruby: github.com/michelson/lazy_high_charts.

tee