我正在尝试使用此链接在我的 rails 应用程序中实现速度计
但我收到以下错误
Uncaught ReferenceError: google is not defined
(anonymous function)
这是我的示例咖啡脚本代码
$(document).ready ->
drawChart = ->
data = google.visualization.arrayToDataTable([
[
'Label'
'Value'
]
[
'Memory'
80
]
[
'CPU'
55
]
[
'Network'
68
]
])
options =
width: 400
height: 120
redFrom: 90
redTo: 100
yellowFrom: 75
yellowTo: 90
minorTicks: 5
chart = new (google.visualization.Gauge)(document.getElementById('widget-inner'))
chart.draw data, options
setInterval (->
data.setValue 0, 1, 40 + Math.round(60 * Math.random())
chart.draw data, options
return
), 13000
setInterval (->
data.setValue 1, 1, 40 + Math.round(60 * Math.random())
chart.draw data, options
return
), 5000
setInterval (->
data.setValue 2, 1, 60 + Math.round(20 * Math.random())
chart.draw data, options
return
), 26000
return
google.load 'visualization', '1.0', 'packages': [ 'gauge' ]
google.setOnLoadCallback drawChart
这是我的 index.html.haml 文件,我试图在其中添加给定的速度计。
.content-container.widgets-container
%h2 "This is Client Manager Dashboad page"
= link_to "Add New Widget", admin_widgets_path, :class => "btn btn-info"
.widgets-wrapper
#widget-1.col-sm-4
.widget-inner#widget-inner
我还在布局中添加了jsapi脚本文件
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
谁能告诉我如何解决给错误。
我正在使用rails 3.2.11和ruby 1.9.3