jQuery 类型错误:$(...).highcharts 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15745093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TypeError: $(...).highcharts is not a function
提问by sakar
I had included the jQuery_1.8.2 js file and then included this code but iam getting the error..
我已经包含了 jQuery_1.8.2 js 文件,然后包含了这段代码,但是我收到了错误..
TypeError: $(...).highcharts is not a function [Break On This Error]
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
TypeError: $(...).highcharts 不是函数 [Break On This Error]
数据:[3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
i just created a div with id container ..where i went wrong..any order of placing js files wrong..?How to resolve this issue..?
我刚刚创建了一个带有 id 容器的 div ..我出错的地方..放置 js 文件的任何顺序错误..?如何解决这个问题..?
<script>
buildHighCharts();
function buildHighCharts(){
$('#container').highcharts({
chart: {
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
}
</script>
<script type="text/javascript" src="js/highcharts1/highcharts-2.3.5.js"></script>
<script type="text/javascript" src="js/highcharts1/modules/exporting-2.3.5.js"></script>
回答by Matt Ball
any order of placing js files wrong..?
放置js文件的任何顺序错误..?
Yes. Your highcharts setup code needs to come afterthe script tags that loads the highcharts library.
是的。您的 highcharts 设置代码需要在加载 highcharts 库的脚本标签之后。
<script type="text/javascript" src="js/highcharts1/highcharts-2.3.5.js"></script>
<script type="text/javascript" src="js/highcharts1/modules/exporting-2.3.5.js"></script>
<script>
function buildHighCharts(){ ... }
</script>
回答by epascarello
You are using highcharts before you added it to the page. The includes need to come before!
在将它添加到页面之前,您正在使用 highcharts。包括需要先来!