我正在尝试在 ActiveAdmin 的仪表板中包含一个包含部分内容的部分。该部分出现,但它是空白的 - 如何使部分出现?我想显示一个 Highcharts 图表。
这是我的代码:
仪表板.rb:
section "Business Summary", do
div do
render 'graph'
end
end
_graph.html.erb(位于 app/views/admin/dashboard):
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
xAxis: {
categories: ['Automotive', 'Agency', 'Contractor', 'Country Club', 'Other']
},
yAxis: {
min: 0,
title: {
text: 'Business Summary'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: 100,
verticalAlign: 'top',
y: 0,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' + 'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'Mobile',
data: [5, 3, 4, 27, 2]},
{
name: 'Foursquare',
data: [2, 2, 3, 2, 1]},
{
name: 'Facebook',
data: [3, 4, 4, 2, 5]},
{
name: 'Yelp',
data: [3, 4, 4, 2, 5]},
{
name: 'Google',
data: [3, 4, 4, 2, 5]}]
});
});
});
</script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>