ActiveAdmin 数据图表
Gemfile
Gemlist:
执行$ bundle install
ActiveAdmin 引入图表js库
#config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
config.register_javascript 'https://www.gstatic.com/charts/loader.js'
end
# app/assets/javascripts/active_admin.js.coffee
#= require active_admin/base
#= require chartkick
ActiveAdmin 添加图表页面
$ rails g active_admin:page StuUserChart
Running via Spring preloader in process 87926
create app/admin/stu_user_chart.rb
# app/admin/stu_user_chart.rb
ActiveAdmin.register_page "StuUserChart" do
content do
column_chart [["2016-01-01", 30], ["2016-02-01", 54]], stacked: true, library: {colors: ["#D80A5B", "#21C8A9", "#F39C12", "#A4C400"]}
#para line_chart StuUser.group_by_day(:created_at).count
end
end