Googlecharts gem - where do I put the require 'gchart'
On the following page it says how to use the googlecharts gem
http://googlecharts.rubyforge.org/
It has a line that says
require 'gchart'
Where do I put this? In the gemfile or the controller?
EDIT: In my view file I have:
<%
require 'gchart'
Gchart.line(:size =&开发者_开发问答gt; '200x300',
:title => "example title",
:bg => 'efefef',
:legend => ['first data set label', 'second data set label'],
:data => [10, 30, 120, 45, 72])
%>
But the above does not display an image
EDIT 2: The chart is now working, here is the code I used
<% require 'gchart' %>
<img src="<%=Gchart.line(:data => [0, 40, 10, 70, 20])%>"/>
You can specify a require statement in your Gemfile
. See Bundler documentation.
gem "googlecharts", :require => "gchart"
You have to restart your server
精彩评论