Charts library for Ruby - ruby-on-rails

I am looking for a quite specific tool for generating charts, within Ruby on Rails application. I have done a research and couldn't find a solution that suits me.
Maybe you've bumped upon it and could just point me to it with a link? :)
My requirements for a solution are:
it has to feature basic chart types
like Pie, Bar, Stacked Bar, Line.
it has to have basic configuration of
a chart like legend, axis
description.
it has to be able to generate and save chart into image file without
actually rendering it in a browser
being a Ruby library would be nice,
but it is not obligatory
not being Gruff Graphing Library, I
am looking for something more up to
date, with less issues.
If you are aware about something, please post a link - it'll take you just a few seconds.

I think, that it is what you're looking for.
http://highcharts.com/
https://github.com/loudpixel/highcharts-rails

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.

The only one that has satisfied all these conditions:
I have been able to make it works without need of install weird dependencies
Not has an HTML context requirement (all JS libraries)
Not depends on GCharts (net traffic dependency)
Exports to static graphic format
is gerbilcharts

Chartkick!!!
It's super nice. =)

It's been a long time since I asked this question and I see new people coming and posting new answers, which his great. This small post of mine turned out to be a small compendium of available libraries.
I decided to add my two cents. Nowadays whenever I am dealing with charts I usually use Highcharts. Highcharts is a very pleasant library by itself, but additionally there is incredible gem highcharts_on_rails which facilitates creating charts using DSL written in Ruby.
If you found this question and you're looking for options, consider highcharts_on_rails.

This might be able to do what you want:
Gruff

You can use rchart for plotting various chart.

I am using openflashchart
http://pullmonkey.com/projects/open_flash_chart2/
you can save generated json data in database and render when needed

Related

MS Excel type spreadsheet creation using objective-c for iOS app

I have a sample iOS app that generates multiple reports using data in the app.
Those reports looks exactly similar to Microsoft Excel spreadsheets like this.
How can I generate the similar using objective-c. I don't have any idea about how can I create the such grid-view. Do we have any objective-c supported framework or anyhting similar to UITableView to create such spreadsheet.
Any help is greatly appreciated.
I have never seen anything like this open source, and I don't think there is. So I would try to hand make it. I think there are three ways to go:
HTML: This should be the easier way to go. Using a UIWebView to render some pre generated HTML/CSS you can create quite easily that spreadsheet (or even use a JS library).
Using a grid view: Either using the Apple solution (UICollectionView, since iOS 6.0) or a third party (AQGridView,GMGridView, etc. There are several, I have only used AQGridView, and its quite complete). The complexity here, is that this libraries are usually developed to show a grid of UIViews, so it's no easy to make them look like the spreadsheet you want.
CoreGraphics: This is much more complex, as you need to draw all the lines, and then draw the fields, but is by far more flexible. I've developed a library for plotting a Radar Chart (RPRadarChart) using Core Graphics, and it wasn't that hard. I have a github repo with all the code that I used to learn Core Graphics, if you want, take a look at it: RPCGSandbox
Good luck, and if you find a better solution, please let us know.
I was looking for a different solution to this issue, but so far I've found:
https://github.com/mochidev/MDSpreadView
Looks like a spreadsheet, and has a similar interface to what a UITableView uses. I was looking for an alternative because the MDSpreadView doesn't use ARC, has a couple compiler warnings, and when I created a library project for it, I noticed it uses lots of images which do not get copied over by default.
You might want to dig deep into UICollectionView, UICollectionViewFlowLayout and also it would be worth looking into AutoLayout Constraints in iOS6. A helpful link : http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
Use multiple tables as columns and when one scroll you scroll the rest of them as well. I create a grid using that and it was efficient to around 10000 rows and 20 columns. If you want i can guide you how will it be done.

Showing visual Data in Ruby on Rails

Screen shot below, reads data from some database - I think I can get my head around reading data from DB with some RubyOnRails tutorial I am following - but then how should I be able to represent that data in a pretty shape that they want like this picture below?
What tools, frameworks, etc. should I get myself familiar with very quick to be able to represent the data like this?
Since I am should focus on Rails, it would be great if what you suggest is in something that integrate well with Rails too...
Screen shot2: for this one I "think" somehow I can use "Google Charts" but still good to have your suggestions too.
To make charts you use javascript. There is a lot of libraries out there.
Those small charts in the first picture are called sparklelines. They can be made with this jquery plugin
jQuery Sparklines
And this pure javascript tool
sparklines.js
For other charts I think the best free one is the d3 library and spesially the nvd3 library witch is built on top of the d3 library.
There are also some solutions with the Raphaël—JavaScript Library.
One is gRaphaël.
I personally do not like this one, but have a look.
Charting libraries often use SVG's (Scalable Vector Graphics. Go here to learn about SVG and CSS ) to display the charts. And you feed the data from Rails trough JSON.
Rails can render JSON from the controllers and you can use jbuilder "Jbuilder gives you a simple DSL for declaring JSON structures that beats massaging giant hash structures."
I usually end up with a custom class in the lib directory, because charting usually requires a lot of complex queries and handling of data from the database before you can send it to the chart.
You should see these railscasts. railscasts#223 railscasts#223revised
The first uses highcharts (Not free) and the last use morris.js. Morris is rather simple, but in some chases sufficient.
The last one is the best, but I guess you have to get a subscription to see it.
There is a lot to learn here, and that is fun!

rails flash graph/chart plugin

I am looking for a rails flash graph/chart plugin, for drawing
bar chart,
stacked bar chart,
pie chart,
stacked area chart,
and line graphs
which support the below criteria,
1. Customizable tool tip. For eg: when i am drawing a stacked area graph, i want to display all the y axix values for that x axis point as tool tip.
2. Graph should support on click event
3. The graph should be able to send as an image through inline attachment.
4. Column graph, that should be able to display the value above the bar.
5. Should be able to turn off the animation
6. We can draw two y axis
Any help is highly appreciated.
Thanks in advance.
Nithy"
EDIT: I am willing to purchase a commercial license if its servers the purpose.
I don't know which ones will have all the features that you want but I was playing with charts a while ago and this is a list of some possibilities:
Ziya(http://ziya.liquidrail.com/) - Rails plugin
AmCharts (http://www.amcharts.com/) - The one I ended up using because of flexibility - No rails plugin but it is quite simple to deploy using with rails XML support (I guess it does export images and has all the features you want though it might take a little while to understand and make full use of it)
Fusion Charts (http://www.fusioncharts.com/) - Seems to be a good option if you are willing to inve$t some money on it
Gruff (http://nubyonrails.com/pages/gruff) - Also rails plugin - I don't remember anymore why I decided against it but I think it was because of the lack of animation
OpenFlash (http://openflashchart.com/) - I liked this one though I just used as a proof of concept
I also did try the Timeplot (http://www.simile-widgets.org/timeplot/) that is totally javascript because I had a problem with the amount of points it was required for my charts and the flash-based solutions had several limitations on that. Though I gave it up because of deployment time contraints.
Hope it helps.
Check out Highcharts http://www.highcharts.com/
Cheers,
I also heavily use AmCharts in conjonction with the Ambling Rails plugin.
If you go this way, know that you will pass time in the AmCharts reference documentation for fine-tuning the parameters of your charts. But it's worthwhile considering the results it give.

Comprehensive graphing and charting solutions...?

I have need to produce LINE, BAR, and PIE charts in Rails. I have found several that do all these. However the one caveat is that I can never find a solution that does all as well as XY-SCATTER. I've looked at Gruff,Scruffy,Gnuplot, etc. and none of them do "everything". Can anyone recommend a local (i.e. doesn't require network connectivity) library that can accommodate? GoogleCharts isn't an option as some of this will occur on closed networks.
Best.
If you don't mind commercial solutions, take a look at ChartDirector.
Open Flash Chart Plugin for Ruby on Rails - Graphs
FusionCharts is pretty good if you don't have a problem with Flash.
Have you checked Google charts? I'm not a web developer myself but it seems that, although not implemented in Rails, you can call the chart API and display the generated image.
Looking at the available chart types, it can give you all the types you want.
Edit: A search turned up this google-chart-on-rails wrapper.

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)?
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
If you don't need images, and can settle on requiring JavaScript, you could try a client-side solution like the jQuery plugin flot.
I am a fan of Gruff Graphs, but Google Charts is also good if you don't mind relying on an external server.
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.
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.
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.
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.
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.
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/
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
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]
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.
You should take a look at Dmitry Baranovskiy's Javascript library called Raphaël.
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/
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.
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.
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/
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.
I personally prefer JavaScript-based charts over Flash. If that's ok, also check out High Charts. A Rails plugin is also available.
The gchartrb gem is no longer maintained, it seems. The author points to these gems:
googlecharts
gchart (seems abandoned as well)
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).
This isn't specifically RoR however, it is pretty slick port of Gruff to javascript: http://bluff.jcoglan.com/
ChartDirector. Ugly API, but good, server-side image results. Self contained binary.
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.
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.
FusionCharts 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.
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
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.
HighChart - A charting library written in pure JavaScript
Gems like highchart-rails, lazy-high-chart makes the integration with rails easier
gem 'chart' makes it easy to add ChartJS and NVD3 charts to rails.

Resources