installation
# Add this line to your application's Gemfile:
gem "chartkick" # This is not optional. Without it, function (e.g. line_chart) won't work even if js is ready.
# For Rails 6 / Webpacker, run:
yarn add chartkick chart.js
# And in app/javascript/packs/application.js, add:
require("chartkick")
require("chart.js")
chart library
Google chart
<%= javascript_include_tag "https://www.gstatic.com/charts/loader.js" %>
AIzaSyCo0AKH9n0-vu92BsU9TwUDKjpmi6c8HZU
Set it
<script type="text/javascript">
google.charts.load('current', {
'packages':['geochart'],
'mapsApiKey': 'AIzaSyCo0AKH9n0-vu92BsU9TwUDKjpmi6c8HZU'
});
</script>
NOTE: I tried to set it in config/initializer/chartkick.rb
Chartkick.options = {
language: "en",
mapsApiKey: "AIzaSyCo0AKH9n0-vu92BsU9TwUDKjpmi6c8HZU", // NOT WORK
height: "400px", // SEEMS WORK
colors: ["#b00", "#666"]
}
Chartkick.configure({language: "de", mapsApiKey: "..."}) // ERROR to load, no configure function.