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

Ruby on-RailsRubyCharts

Ruby on-Rails Problem Overview


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

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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

Solution 2 - Ruby on-Rails

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

Solution 3 - Ruby on-Rails

I am a fan of Gruff Graphs, but Google Charts is also good if you don't mind relying on an external server.

Solution 4 - Ruby on-Rails

It requires flash and isn't free (though inexpensive): amcharts.

I've used it successfully and like it. I evaluated a number of options a while back and chose it. At the time, however, Google Charts wasn't as mature as it seems to be now. I would consider that first if I were to re-evaluate now.

Solution 5 - Ruby on-Rails

There's also Scruffy. I took a look at the code recently and it seemed easy to modify/extend. It produces svg and (by conversion) png.

Solution 6 - Ruby on-Rails

Have you tried the Google Charts API? - web service APIs don't really come much simpler. It's free to use, simple to implement, and the charts don't look too shoddy.

Solution 7 - Ruby on-Rails

Open Flash Chart II is a free option that gives very nice output. It does, as you'd expect, require Flash.

Fusion Charts is even nicer, but is $499. In researching this, I found a cut-down free version that might serve your needs.

Solution 8 - Ruby on-Rails

I 2nd the vote for flot. The latest version lets you do some animations and actions that I previously thought would only be possible via Flash. The documentation is fantastic. It simple to write by hand, but for simple cases it gets even easier with a Rails plugin called flotilla. You should check out the examples page for a better idea of what it's capable of. The zooming and hover capabilities are especially impressive.

Solution 9 - Ruby on-Rails

The new Google Visualization appears to produce charts that are of more varied type, better looking and interactive than Google Graphs.

http://code.google.com/apis/visualization/

Solution 10 - Ruby on-Rails

Morris.js is nice and open source. I would like to choose it comparing to highcharts. There is a new great video tutorial from Railscasts

Solution 11 - Ruby on-Rails

I've just found ZiYa produces some really sexy charts and is Rails specific.

The downsides are it uses Flash and if you don't want the sites to link to XML/SWF page it costs $50 per site.

[I've not decided on it yet, but wanted to throw it out there in case people want to vote it up]

Solution 12 - Ruby on-Rails

I've used Fusion Charts extensively from within a Java web application, but it should work the same way from Rails since you're just embedding a Flash via HTML or JavaScript and passing it XML data. It's a slick package and their support has always been very responsive.

Solution 13 - Ruby on-Rails

You should take a look at Dmitry Baranovskiy's Javascript library called Raphaël.

Solution 14 - Ruby on-Rails

Google charts is very nice, but it's not a rails only solution. You simple use the programming language of your choice to dynamically produce urls that contain the data and google returns you back a nice image with your chart.

http://code.google.com/apis/chart/

Solution 15 - Ruby on-Rails

In the old days, I decided to roll my own (using RVG/RMagick), mainly because Gruff didn't have everything I wanted. The downside was that finding and eliminating all the bugs in graphing code is a pain. These days Gruff is my choice as it's really gone forward in terms of customization and flexibility.

The standard Gruff templates/color choices suck though, so you'll need to get your hands dirty for best results.

Solution 16 - Ruby on-Rails

Regarding amcharts, there's a "free" version with a very few restrictions that generates Flash charts including the 'chart by amCharts.com' mention.

And there's a nice plugin, ambling, that provides you with some helper methods to easily add charts to your views. Please note that amCharts.com reference documentation is still a must to tailor the chart to your requirements.

Solution 17 - Ruby on-Rails

GoogleCharts and Gruff charts are great, but sometimes they lack some features that I need for more scientific plotting. There is a gem for gnuplot which may be helpful for some of these situations.

http://rgplot.rubyforge.org/

Solution 18 - Ruby on-Rails

I have started using protovis to generate SVG charts with javascript. My basic approach in rails is to have a controller that returns the data to be charted as JSON, and scoop it up with a bit of javascript and protovis.

Only downside, is that full IE support (Since it is based on SVG) is currently unavailable straight out of the box... However, current patches go a fair way to providing IE support, details of which can be found here.

Solution 19 - Ruby on-Rails

I personally prefer JavaScript-based charts over Flash. If that's ok, also check out High Charts. A Rails plugin is also available.

Solution 20 - Ruby on-Rails

The gchartrb gem is no longer maintained, it seems. The author points to these gems:

Solution 21 - Ruby on-Rails

We do this by shelling out to gnuplot to generate the charts as PNGs server-side. It's a bit old-school and the charts aren't interactive but it works and is cacheable.

(The other reason we do this is so we can put exactly the same chart in the PDF version of the report).

Solution 22 - Ruby on-Rails

This isn't specifically RoR however, it is pretty slick port of Gruff to javascript: http://bluff.jcoglan.com/

Solution 23 - Ruby on-Rails

ChartDirector. Ugly API, but good, server-side image results. Self contained binary.

Solution 24 - Ruby on-Rails

FWIW, I'm not a fan of using Google Charts when fit & finish is important. I find that the variables for sizing, in particular, are unpredictable - the chart does its own thing.

I haven't yet played with Gruff/Bluff/etc., but for a higher-profile project I won't use Google Charts.

Solution 25 - Ruby on-Rails

If you want quite sexy charts, easy to generate, and you can enable Flash, then you should definitely have a look at maani.us xml/swf charts.

Some XML builder behind it and you're ready to go.

Solution 26 - Ruby on-Rails

http://www.fusioncharts.com">FusionCharts</a> is a very good charting product. Works well with RoR. Their support and forums are good. The free version of this product has limited number of charts and features, but no watermark.

Solution 27 - Ruby on-Rails

I just started using googlecharts for my rails 3 project. It is nice and clean, and seems to be the only google visualization api based gem which is alive. Others are inactive and mostly use the old google charts api (released somewhere in 2007-2008).

https://github.com/mattetti/googlecharts

Solution 28 - Ruby on-Rails

D3 has become my preferred way add great looking charts to web apps. You have to do a little mroe work that some other frameworks, but the appearance and control outweighs that.

I primarily use SVG, which means no IE8, but that is becoming less of an issue.

Solution 29 - Ruby on-Rails

HighChart - A charting library written in pure JavaScript

Gems like highchart-rails, lazy-high-chart makes the integration with rails easier

Solution 30 - Ruby on-Rails

gem 'chart' makes it easy to add ChartJS and NVD3 charts to rails.

Solution 31 - Ruby on-Rails

My own option for people who need the support of multiple types of charts and rails helpers to simplify integration - https://github.com/railsjazz/rails_charts

It's based on Apache eCharts.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRichHView Question on Stackoverflow
Solution 1 - Ruby on-RailsClinton DreisbachView Answer on Stackoverflow
Solution 2 - Ruby on-RailsBen CrouseView Answer on Stackoverflow
Solution 3 - Ruby on-RailsDoug MooreView Answer on Stackoverflow
Solution 4 - Ruby on-RailsOttoView Answer on Stackoverflow
Solution 5 - Ruby on-RailsMatthias WinkelmannView Answer on Stackoverflow
Solution 6 - Ruby on-RailsDavid HeggieView Answer on Stackoverflow
Solution 7 - Ruby on-RailsClinton DreisbachView Answer on Stackoverflow
Solution 8 - Ruby on-RailsJerry CheungView Answer on Stackoverflow
Solution 9 - Ruby on-RailsRichHView Answer on Stackoverflow
Solution 10 - Ruby on-RailsSteven YueView Answer on Stackoverflow
Solution 11 - Ruby on-RailsRichHView Answer on Stackoverflow
Solution 12 - Ruby on-RailsBrian DeterlingView Answer on Stackoverflow
Solution 13 - Ruby on-RailsNathan de VriesView Answer on Stackoverflow
Solution 14 - Ruby on-Railsdelux247View Answer on Stackoverflow
Solution 15 - Ruby on-RailsDan HarperView Answer on Stackoverflow
Solution 16 - Ruby on-RailsLaurent FarcyView Answer on Stackoverflow
Solution 17 - Ruby on-RailsBryan WardView Answer on Stackoverflow
Solution 18 - Ruby on-RailsClintonView Answer on Stackoverflow
Solution 19 - Ruby on-RailsPreston LeeView Answer on Stackoverflow
Solution 20 - Ruby on-RailsThiloView Answer on Stackoverflow
Solution 21 - Ruby on-RailsAndrewRView Answer on Stackoverflow
Solution 22 - Ruby on-RailsTony PitaleView Answer on Stackoverflow
Solution 23 - Ruby on-RailsJordi BunsterView Answer on Stackoverflow
Solution 24 - Ruby on-RailsscottruView Answer on Stackoverflow
Solution 25 - Ruby on-RailsThibaut BarrèreView Answer on Stackoverflow
Solution 26 - Ruby on-RailsSrividya SharmaView Answer on Stackoverflow
Solution 27 - Ruby on-Railsamit_saxenaView Answer on Stackoverflow
Solution 28 - Ruby on-RailsRichHView Answer on Stackoverflow
Solution 29 - Ruby on-RailsushaView Answer on Stackoverflow
Solution 30 - Ruby on-RailsytbryanView Answer on Stackoverflow
Solution 31 - Ruby on-RailsIgor KasyanchukView Answer on Stackoverflow