【发布时间】:2013-10-10 22:47:04
【问题描述】:
我对 Rails 很陌生,我试图将 javascri 图表从 Highcharts.com 导入到我的 Rails 应用程序中。但由于某种原因,视图 Container 仍然是空的。
我已下载软件包并将其添加到 vendor/assets/javascripts
我在 application.js 文件中添加了 //= require highcharts。
这是我的 users.js 文件
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
});
});
我已将其添加到 show.html.erb
<div id="container" class="container" style="width:100%; height:400px;">
</div>
有人知道如何在 show.html.erb 上显示图表吗?
提前致谢!
【问题讨论】:
标签: javascript jquery ruby-on-rails ajax