gpt4 book ai didi

javascript - Rails - Heroku 上的 Highcharts - 获取 'ReferenceError: Highcharts is not defined'

转载 作者:行者123 更新时间:2023-12-03 04:27:44 25 4
gpt4 key购买 nike

我正在使用 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]}]
});

最佳答案

我建议使用这个 gem:https://github.com/market76/lazy_high_charts

它使得在 Rails 应用程序中使用 High Charts 变得更加容易。您也可以使用 PhantomJS 在服务器端导出图形图像。

关于javascript - Rails - Heroku 上的 Highcharts - 获取 'ReferenceError: Highcharts is not defined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13899967/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com