I am using chartkick gem to display chart. I have followed the proper installation documentation but whenever I am trying to use their methods like
timeline [["Washington", "1789-04-29", "1797-03-03"], ["Adams", "1797-03-03", "1801-03-03"], ["Jefferson", "1801-03-03", "1809-03-03"]]
It's showing error in the firebug ReferenceError: Chartkick is not defined
Depending on which charting library you prefer, you need to include it's javascript path in your view file. That solved the issue for me.
<%= javascript_include_tag "path/to/highcharts.js", "chartkick" %>
Lets walk through all potential pitfalls (non-highcharts solution)
GEMFILE:
make sure to run bundle install afterwards
include 'chartkick'
APPLICATION.JS:
in your config/environments/development.rb
you might have set config.assets.compress = true
and config.assets.compile = true
and config.serve_static_files = true
, which would mean you would need to recompile your assets to see changes in development.
//= require chartkick
HAML:
javascript include line begins '=' not '-'. @report.data should be active record relation
= javascript_include_tag '//www.google.com/jsapi', 'chartkick'
= pie_chart @report.data
SERVER:
If using spring, try spring stop
. Restart your rails server. Force reload page cmd+shift+R
or ctrl+shift+R
(not all browsers can do this)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With