What is your preferred way to produce charts in a Ruby on Rails web application?

RichH picture RichH · Sep 17, 2008 · Viewed 22.1k times · Source

I'd like to add some pie, bar and scatter charts to my Ruby on Rails web application. I want want them to be atractive, easy to add and not introduce much overhead.

What charting solution would you recommend?
What are its drawbacks (requires Javascript, Flash, expensive, etc)?

Answer

Clinton Dreisbach picture Clinton Dreisbach · Sep 17, 2008

Google Charts is an excellent choice if you don't want to use Flash. It's pretty easy to use on its own, but for Rails, it's even easier with the gchartrb gem. An example:

GoogleChart::PieChart.new('320x200', "Things I Like To Eat", false) do |pc| 
  pc.data "Broccoli", 30
  pc.data "Pizza", 20
  pc.data "PB&J", 40 
  pc.data "Turnips", 10 
  puts pc.to_url 
end