Это форк Vinaora Nivo Slider, пришлось переименовать, в силу требования JED. Даже старую версию качать можно было только с варезных сайтов, нашпигованную троянами. Зачем оно такое, согласитесь.
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Time', 'TempC'],
<% @data.css("hourly").each do |hrly| %>
['<%= hrly.css("time").text %>',<%= hrly.css("tempC").text %>],
<% end %>
]);
var options = {
title: 'Temperature forecast'
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div id="chart_div" style="width: 100%; height: auto;"></div>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
$(function() {
Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Temperature conditions'
},
subtitle: {
text: 'Source: WorldWeatherOnline.com'
},
xAxis: {
categories: [<% @data.css("hourly").each do |hrly | %> <%= hrly.css("time").text %>, <% end %>]
},
yAxis: {
title: {
text: 'Temperature (°C)'
}
},
tooltip: {
headerFormat: '<b>Temperature</b><br>',
pointFormat: 'TempC: {point.y:.f} C°'
},
plotOptions: {
spline: {
marker: {
enabled: true
}
}
},
series: [{
name: 'Time',
data: [<% @data.css("hourly").each do |hrly | %> <%= hrly.css("tempC").text %>, <% end %>]
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
If you use turbolinks, try to disable it in that page, because I have similar problems with google maps apis.
to disable turbolinks you can add this to your application.html.erb
<body <%= yield(:body_attributes) %>>
then in your view.html.erb add this in first line
<%= content_for(:body_attributes, 'data-no-turbolink') %>
you can also disable turbolink with link_to
<%= link_to 'link_name', your_link_path, 'data-no-turbolink' => true %>
if you use rails/turbolinks 5 change data-no-turbolink into data-turbolinks and switch the boolean value
also try to put your javascript in the bottom. to make it loaded after the html dom (try to put your script in bottom, and your div in top).
<%= link_to 'link_name', your_link_path, data:{turbolinks: 'false'} %>
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
//= xxxrequire turbolinks
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.