ReferenceError: Chartkick not defined

I use chartkick gem to display a chart. I followed the correct installation documentation, but whenever I try to use their methods, for example

timeline [["Washington", "1789-04-29", "1797-03-03"], ["Adams", "1797-03-03", "1801-03-03"], ["Jefferson", "1801-03-03", "1809-03-03"]] 

It shows an error in firebug ReferenceError: Chartkick not defined

+5
source share
3 answers

Depending on which graphics library you prefer, you need to include a javascript file in it. This solved the problem for me.

 <%= javascript_include_tag "path/to/highcharts.js", "chartkick" %> 
+3
source

Lets go through all potential traps (solution without high cards)


Gemfile:

make sure package installation is subsequently started

 include 'chartkick' 

APPLICATION.JS:

in your config/environments/development.rb you could set config.assets.compress = true and config.assets.compile = true and config.serve_static_files = true , which would mean that you would need to recompile your assets to see the changes in developing.

 //= require chartkick 

Haml:

javascript include line starts with '=' not '-'. @ report.data should be an active post relation

 = javascript_include_tag '//www.google.com/jsapi', 'chartkick' = pie_chart @report.data 

SERVER:

When using spring, try spring stop . Reboot the rails server. Restart page reload cmd+shift+R or ctrl+shift+R (not all browsers can do this)

+2
source

Source: https://habr.com/ru/post/1209017/


All Articles