我正在使用highcharts绘制一些图表。它本地工作得很好,但是当部署到heroku时,我得到这个javascript错误,说没有定义Highcharts。我虽然可能没有预编译javascript文件,但我检查了heroku日志,我发现它确实得到了预编译。我也去 myapp.herokuapp.com/assets/highcharts.js ,我在那里找到它。 所以我不确定问题是什么。
感谢任何帮助,谢谢。
---这是页面的html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/assets/application-eb12a5437181ffb065f7793b96f720c9.css" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/application-b5b4fd7bed721cbc4cc70b5a8c8654e9.js" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
....
<div id="container2" style="min-width: 400px; height: 100%; margin: 0 auto"></div><br><br />
<script>
$(function () {
var chart2;
$(document).ready(function() {
chart2 = new Highcharts.Chart({
chart: {
renderTo: 'container2',
type: 'bar',
height: 450
},
title: {
text: 'Questions'
},
subtitle: {
text: 'number of students with answer'
},
xAxis: {
categories: ["Part3 00:03:31", "Part4 00:03:41", "Part5 00:06:17"],
labels:{
useHTML: true}
},
yAxis: {
min: 0,
allowDecimals: false,
title: {
text: 'Number of Students'
}
},
legend: {
enabled: false,
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
shadow: true
},
tooltip: {
formatter: function() {
return ''+
this.series.name+': '+ this.y +' student(s)<br>'+question(this.point.x, this.series.name);
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{"name":"Answer 1","data":[11,7,6]},{"name":"Answer 2","data":[4,6,2]},{"name":"Answer 3","data":[5,7,6]},{"name":"Answer 4","data":[0,0,6]}]
});
答案 0 :(得分:-1)
我建议使用这个宝石:https://github.com/market76/lazy_high_charts
它使得在Rails应用程序中使用High Charts变得更加容易。您也可以使用PhantomJS导出图形图像服务器端。