gpt4 book ai didi

javascript - 引用错误 : HighCharts is not defined

转载 作者:数据小太阳 更新时间:2023-10-29 04:44:13 26 4
gpt4 key购买 nike

我在 index.html.erb 文件上的 Rails 应用程序上使用 highstocks 渲染图表,但是当我尝试加载图表时,我在 firebug 控制台上收到以下错误,

ReferenceError: HighCharts is not defined
new HighCharts.Chart({

我的index.html.erb文件如下

<div id="quotes_chart", style="width=560px; height:300px;">
<script>
$(function(){
new HighCharts.Chart({
chart : {
renderTo: "quotes_chart"
},
title : {
text: "Daily trades"
},
xAxis : {
type: "datetime"
},
yAxis : {
title: {
text: "Shillings"
}
},
tooltip : {
formatter: function(){
return HighCharts.dateFormat("%B %e, %Y", this.x) + ': ' + "Kshs" + Highcharts.numberFormat(this.y, 2);
}
},
series: [
<% { "Telecommunication" => StockQuote.telecomm, "Agriculture" => StockQuote.agric }.each do |name, prices|
%>
{
name: <%= name %>,
pointInterval: <%= 1.day * 1000 %>,
pointStart: <%= 2.weeks.ago.to_i * 1000 %>,
data: <%= (2.weeks.ago.to_date..Date.today).map { |date| StockQuote.price_on(date).to_f}.inspect%>
},
<% end %>
]
});
});
</script>
</div>

在我的application.html.erb中是这样的:

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="components/highstock/highstock.js"></script>
<%= javascript_include_tag "jquery-1.11.0.min", "highcharts" %>

在我的应用程序 assests/javascripts 文件夹中,我同时拥有从 highcharts.com 下载的 jquery-1.11.0.min.js 和 highcharts.js 文件

我可能做错了什么?

最佳答案

var chart=null;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'bar'
},
title: {
text: '${model.title}'
}
...

将图表设置为空,因为此错误可能是由于您可能没有意识到的多重声明而发生的。假设所有导入都是正确的

关于javascript - 引用错误 : HighCharts is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23506047/

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