我已經包括了jQuery_1.8.2 js文件,然後包括在此代碼,但IAM得到錯誤的功能..
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]
我剛剛創建一個div與id容器..我錯了..任何順序 放置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>
你在哪裏調用'buildHighCharts()'? – epascarello
剛剛更新腳本..與函數調用.. – sakar
這不可能創建你所看到的問題 - 但你真的不應該在聲明它之前調用該函數。 –