What Is Your Preferred Way to Produce Charts in a Ruby on Rails Web Application

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

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

Charts in Ruby on rails 3 web app

Google has a great library for drawing charts with HTML5 and JavaScript. It's called Google Chart Tools.

You can pick the chart type you want from their Chart Gallery and use it with JavaScript. Even if you don't have much JavaScript skills, the examples should help you to get the job done.

Charts library for Ruby

I've made a number of useful charts with the Google Chart API. There are a few gems: googlecharts, gchartrb. I haven't used them but they look like a good first cut.

As to not displaying it you can just make the call and save the result. No need to render, just make the call, get the URL, and fetch the file.

Rails: How to draw charts?

You would probably be better off producing them in javascript. There are lots of great libraries out there; perhaps start with flot.

If you need more control or more exotic charts, try d3.



Related Topics



Leave a reply



Submit