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?
Charts 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.