With gem added to the Gemfile
and you have run the bundle install
command.
Add this to your application.js
file
//= require jquery-1.8.2.min
//= require jquery-ui-1.8.1.custom.min
//= require scripts
//= require_directory.
//= require scripts
// if you have javascripts or jQuery functions in script.js file
Add the highcharts.js
under the app/assets/javascripts
directory where all your jQuery
are present.
Now just use the javascript include tag in your layout file as
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
now you are all set.
your html markup as it is
<div id="container" style="width:100%;height:400px;"></div>
your script as it is
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
});
});
OUTPUT
It worked for me.