Rails Active Admin + Chartkick = Not working?

I was trying to use Chartkick to generate graph that shows on rails active admin dashboard. Here is the tutorial I am using: http://www.patrickedelman.com/simple-charting-for-activeadmin/

However, the graph did not show up, instead, it shows "Loading..."

I already include javascript_include_tag "//www.google.com/jsapi", "chartkick" and gem chartkick is installed, but it still does not work.

Please help! Thank you.

Answers


Don't forget to add #= require chartkick to active_admin.js.coffee.

To render a chart in AA dashboard, go with:

div class: 'custom-class' do
  h3 'Your name for a chart'
  @metric = Model.group(:attribute).count #whatever data you pass to chart
  render partial: 'metrics/partial_name', locals: {metric: @metric}
end

This file

partial: 'metrics/partial_name'

lays under app/views/metrics/partial_name directory, and could have the following structure:

_partial_name.html.haml:

= javascript_include_tag "//www.google.com/jsapi", "chartkick"
= pie_chart metric 

Having this you should be ok with using chartkick.


Need Your Help

Make WinForms application WinForms/Console hybrid

c# winforms console hybrid

I have a WinForms application that I'd like to have ability to run as a console application too (with 2 command-line arguments).

How do you override a method for a java type instance with Groovy meta programming?

groovy metaprogramming

I am trying to override the functionality of a method of a java type instance in my Groovy code but I am getting a classcast exception.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.