as a newbie in Rails, i'm trying to find a good open charting library to work with rails.
With some research I've found gRaphael, and it seems it could just work for me, if i just could use it in my rails app.. I found a gem that seems to aggregate graphael (graphael-rails), but actually do not understand how to use it, since i cannot reference to its files, and have to copy/paste them to my local assets directory.
I've followed the guidelines and have put raphael-min.js, g.raphael.js and g.pie.js inside my assets/javascripts folder, as well as a demo.css file in the stylesheets folder, and some background images.
I added to application.html.erb
<%= javascript_include_tag "raphael-min.js","g.raphael.js","g.pie.js", "application" %>
and to my view :
...
<div id="holder"></div>
...
<%= javascript_tag "
var r = Raphael(""holder"");
r.piechart(320, 240, 150, [55, 20, 13, 32, 5, 1, 2, 10]);
r.text(320, 70, 'Static Pie Chart').attr({ font: '20px ""Fontin Sans"", Fontin-Sans, sans-serif' });
" %>
</body>
The problem is that for some reason, the piechart function is not being built into Raphael DOM object....
What might i be doing wrong? I've spent an entire day looking for answers on this and would appreciate any help here.
Here are the scripts being load to my html file
<script type="text/javascript" src="/assets/raphael-min.js?body=1">
<script type="text/javascript" src="/assets/g.raphael.js?body=1">
<script type="text/javascript" src="/assets/g.pie.js?body=1">
<script type="text/javascript" src="/assets/jquery.js?body=1">
<script type="text/javascript" src="/assets/jquery_ujs.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-transition.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-alert.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-button.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-carousel.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-collapse.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-dropdown.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-modal.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-scrollspy.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-tab.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-tooltip.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-popover.js?body=1">
<script type="text/javascript" src="/assets/bootstrap-typeahead.js?body=1">
<script type="text/javascript" src="/assets/bootstrap.js?body=1">
<script type="text/javascript" src="/assets/g.pie.js?body=1">
<script type="text/javascript" src="/assets/g.raphael.js?body=1">
<script type="text/javascript" src="/assets/jquery-ui.min.js?body=1">
<script type="text/javascript" src="/assets/raphael-min.js?body=1">
<script type="text/javascript" src="/assets/retailers.js?body=1">
<script type="text/javascript" src="/assets/application.js?body=1">
and my application.js file contents:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
Notice that raphael's js files are being loaded twice, and the only reason i include them in my application.html.erb file is that if i don't, than raphael-min.js gets loaded after g.raphael.js and g.pie.js which depend on it, and i get javascript errors...
Any suggestions on this?
Thanks