Connect Raphael with Rails

This is a high level question about web frameworks, which, as a desktop application developer, I have little knowledge.

I plan to create a web application that visualizes some of the data stored in the database. I plan to use Rails for a custom request. For visualization, a good JA Raphael library. Will it be a significant task to try connecting Rails to this library?

Any recommendations for replacing these 2 are welcome.

+6
javascript ruby-on-rails raphael
source share
6 answers

Not much needs to be done to connect Rails and Raphaël. Raphaël is a Javascript library and therefore runs fully on the client, while Rails is a server-side web application platform. All you really need to do to integrate them includes Raphaël on your page and provides data for it in a format convenient for use in Javascript; using RESTful controllers that provide data in JSON, it will be easier for you to load data using XMLHttpRequest from a client, which you can display using Raphaël.

+9
source share

Ryan Bates talks about the graphs (including Raphael) in this Railscasts , I'm sure this is a good starting point.

+2
source share

Raphael is a standalone JS library, the server structure / language you choose is really unimportant. You cannot just connect one to the other, but you will have to figure out how to provide Raphael with the data it needs in the format that it expects. The rails will not be better or worse than any other structure.

+2
source share

There should not be any problems, especially because Rails 3 has become an agnostic of the JS library.

Performing a quick cursory search, I saw this library, which could deserve your attention. It doesn't seem to do pie charts, but otherwise it looks good: Flot

This particular library is designed to integrate with jQuery, which is a popular and well-documented JS library that Rails 3 does well.

0
source share

If you feel lazy, you can use a gem that will contain the appropriate files for you.

0
source share

It is very easy. Raphaël is a javascript library, so to use it, put the raphael-min.js file in the app / assets / javascript folder. Then add this line

application / views / layouts / application.html.erb

<!DOCTYPE html> <html> <head> <title></title> <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "raphael-min" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> ... 

Then write your javascript code in the app / assets / javascript / application.js file. That should work.

0
source share

All Articles