Rails Chartkick Gem map loading schedule not found.

I have a Rails 3.2.14 application where I use chartkick and groupdate gem to try to create some basic charts.

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

Here is what my view code looks like:

index.html.erb

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

Here is my application layout, including chartkick and yielding chart_js application.html.erb (layout)

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

Can someone tell me why I get this error and how to fix it? I would really like to start using Chartkick to create simple charts.

+5
source share
5 answers

You may have missed downloading Google charts or Highcharts (adapters).

Try adding this line <%= javascript_include_tag "//www.google.com/jsapi" %> to <%= javascript_include_tag "application", "chartkick" %> . Also check the "Installation" section on the gem homepage (scroll down :)).

+14
source

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

+2
source

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

For example, you will receive an error message Error Loading Chart: No adapter found if, for example, you use the https protocol for your site: https://www.example.com

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

+1
source

If the above is not allowed for someone, one additional possibility is the mixed content problem.

You can verify this by opening the JS console.

Mixed content: the page at ' https://site.io/ ' was loaded on top of HTTPS, but requested an insecure script ' http://www.google.com/jsapi '. This request is blocked; content must be transmitted via HTTPS.

Decision:

Just change this

 http://www.google.com/jsapi 

To do this (add s to http )

 https://www.google.com/jsapi 
+1
source

I had a similar problem when I first tried ChartKick . I get the error " Chart loading error: chart libraries not found - be sure to add one in front of your charts"

Here is how I fixed it.

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

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

Save and update, this should fix it.

All this

Hope this helps.

0
source

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


All Articles