7

I have a Rails 3.2.14 app where I'm using the chartkick and groupdate gem to try to generate some basic charts.

When I load my view I get the error: Error Loading Chart: No adapter found

Here's what my view code looks like:

index.html.erb

<%= line_chart Call.group_by_week(:created_at).count %>

Here's my application layout including chartkick and yielding chart_js application.html.erb (layout)

 <%= javascript_include_tag "application", "chartkick" %>
 <%= yield :charts_js %>

Can anyone tell me why I'm getting this error and how to fix it? I'd really like to start using Chartkick to generate some simple charts.

Austin Richardson
  • 8,078
  • 13
  • 43
  • 49
nulltek
  • 3,247
  • 9
  • 44
  • 94

5 Answers5

17

Probably you missed loading Google Charts or Highcharts (the adapters).

Try adding this line <%= javascript_include_tag "//www.google.com/jsapi" %> before <%= javascript_include_tag "application", "chartkick" %>. Also check the Installation section in gem's home page (scroll down :)).

Ahmad Sherif
  • 5,923
  • 3
  • 21
  • 27
5

To View: Google Charts In your layout or views, add:

<%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>

link: https://chartkick.com/#google-charts

vidur punj
  • 5,019
  • 4
  • 46
  • 65
3

I had a similar issue as well when I first tried out ChartKick. The error message that I got is Error Loading Chart: No charting libraries found - be sure to include one before your charts

Here's how I fixed it.

I simply added the following line of code below to the application.js file in the assets > javascript folder.

//= require Chart.bundle
//= require chartkick

Save and refresh, that should fix it.

That's all

I hope this helps.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
2

Another cause of error can be the protocol you use in the javascript_include_tag.

For instance you will get the error Error Loading Chart: No adapter found if you for instance use protocol https for your website: https://www.example.com

and http in the javascript_include_tag in your code:
<%= javascript_include_tag "http://www.google.com/jsapi", "chartkick" %>

Syksteaz
  • 23
  • 5
1

If above doesn't solve for someone, one additional possibility is a mixed content issue.

You can check this by opening the JS console.

Mixed Content: The page at 'https://site.io/' was loaded over HTTPS, but requested an insecure script 'http://www.google.com/jsapi'. This request has been blocked; the content must be served over HTTPS.

Solution:

Just change this

http://www.google.com/jsapi

To this (add s to http)

https://www.google.com/jsapi
tim_xyz
  • 11,573
  • 17
  • 52
  • 97