简体   繁体   English

活动管理仪表板导轨中的图表集成

[英]Charts integration in active admin dashboard rails

My Dashboard我的仪表盘

section "Graph", do
div do
    render 'graph'
    end
end

_graph.html.erb _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.我将那个 _graph.html.erb 放在哪个文件夹中,以便它可以加载。 is JavaScript in it works correctly after that?在那之后,它里面的 JavaScript 能正常工作吗?

Charts integration on active admin is pretty simple, all you have to use is get chartkick in your Gemfile.主动管理中的图表集成非常简单,您所需要的只是在您的 Gemfile 中获取 chartkick。

Then in your dashboard.rb you can create another panel within a column and show your graph.然后在您的dashboard.rb 中,您可以在一列中创建另一个面板并显示您的图表。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails Stripe集成无活动卡错误 - Rails Stripe integration no active card error 在Active Admin和Ruby on Rails中使用Coffee Script - Using Coffee Script with Active Admin and Ruby on Rails Rails 3.1 - Active_admin和Checkboxes - Rails 3.1 - Active_admin and Checkboxes 在rails_admin仪表板上包括一个自定义js文件 - Including a custom js file on rails_admin dashboard Hystrix仪表板-不显示图表 - Hystrix dashboard - charts are not displayed 在Active Admin(Rails 3.2,Active Admin 1.0)的依存选择下拉列表中找不到错误 - Can't find the error in my dependent select drop down on Active Admin( Rails 3.2, Active Admin 1.0) 当管理员单击菜单时,如何在管理仪表板的颜色区域中激活背景色,它将变为默认设置的背景色 - How to active background color in color sector in admin dashboard while admin clicks on menu it goes to default set background color 尝试让Jquery在Rails和Active Admin中使用动态选择表单 - Trying to get Jquery working with dynamic select forms in Rails and Active Admin 带有React的Admin LTE仪表板 - Admin LTE dashboard with React Google图表可视化实例化问题仪表板 - Google charts visualization instantiateproblem Dashboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM