开发者

Googlecharts gem - where do I put the require 'gchart'

开发者 https://www.devze.com 2023-04-11 23:10 出处:网络
On the following page it says how to use the googlecharts gem http://googlecharts.rubyforge.org/ It has a line that says

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

0

精彩评论

暂无评论...
验证码 换一张
取 消