Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)?

like image 400
RichH Avatar asked Sep 17 '08 20:09

RichH


2 Answers

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 
like image 167
Clinton Dreisbach Avatar answered Sep 21 '22 14:09

Clinton Dreisbach


If you don't need images, and can settle on requiring JavaScript, you could try a client-side solution like the jQuery plugin flot.

like image 43
Ben Crouse Avatar answered Sep 19 '22 14:09

Ben Crouse