Googlecharts宝石 - 我在哪里把要求'gchart' [英] Googlecharts gem - where do I put the require 'gchart'

查看:110
本文介绍了Googlecharts宝石 - 我在哪里把要求'gchart'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的页面上,它说明了如何使用googlecharts gem

On the following page it says how to use the googlecharts gem

http://googlecharts.rubyforge.org/

它有一行说:

It has a line that says

require 'gchart'

我在哪里放置这个?在gemfile或控制器中?

Where do I put this? In the gemfile or the controller?

编辑:
在我的视图文件中,我有:

In my view file I have:

<%
require 'gchart'
Gchart.line(:size => '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

编辑2:
图表现在正在工作,这是我使用的代码

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])%>"/>


推荐答案

您可以在<$ c中指定require语句$ C>的Gemfile 。请参阅 Bundler文档

gem "googlecharts", :require => "gchart"

这篇关于Googlecharts宝石 - 我在哪里把要求'gchart'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆