My Dashboard
section "Graph", do
div do
render 'graph'
end
end
_graph.html.erb
<script type="text/javascript">
$(function(){
new Highcharts.Chart({
chart: {
renderTo: "charts"
},
title: {
text: "Orders"
},
xAxis: {
title: {
text: "X axis"
}
},
yAxis: {
title: {
text: "Y axis"
}
},
series: [{
data: [1,3,5,7]
}]
});
});
In which folder I place that _graph.html.erb so that it can loaded. is JavaScript in it works correctly after that?
My Dashboard
section "Graph", do
div do
render 'graph'
end
end
_graph.html.erb
<script type="text/javascript">
$(function(){
new Highcharts.Chart({
chart: {
renderTo: "charts"
},
title: {
text: "Orders"
},
xAxis: {
title: {
text: "X axis"
}
},
yAxis: {
title: {
text: "Y axis"
}
},
series: [{
data: [1,3,5,7]
}]
});
});
In which folder I place that _graph.html.erb so that it can loaded. is JavaScript in it works correctly after that?
Share Improve this question edited Apr 10, 2021 at 18:20 Robin Daugherty 7,5344 gold badges47 silver badges60 bronze badges asked Oct 28, 2015 at 10:14 user5496955user54969551 Answer
Reset to default 6Charts integration on active admin is pretty simple, all you have to use is get chartkick in your Gemfile.
Then in your dashboard.rb you can create another panel within a column and show your graph. Example:
panel "Top stuff --all name-removed for brevity--" do
# line_chart Content.pluck("download").uniq.map { |c| { title: c, data: Content.where(download: c).group_by_day(:updated_at, format: "%B %d, %Y").count } }, discrete: true
# column_chart Content.group_by_hour_of_day(:updated_at, format: "%l %P").order(:download).count, {library: {title:'Downloads for all providers'}}
# column_chart Content.group(:title).order('download DESC').limit(5).sum(:download)
bar_chart Content.group(:title).order('download DESC').limit(5).sum(:download) ,{library: {title:'Top 5 Downloads'}}
##
# line_chart result.each(:as => :hash) { |item|
# {name: item.title, data: item.sum_download.count}
# }
end
end
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745090484a4610665.html
评论列表(0条)