当我尝试使用简单的highcharts示例时,我收到错误:
Uncaught TypeError: undefined is not a function
除了:
TypeError: undefined is not a function
at Object.Ya.init (https://code.highcharts.com/highcharts.js:190:496)
at Object.Ya (https://code.highcharts.com/highcharts.js:15:312)
at HTMLDocument.eval (eval at <anonymous> (https://localhost:3000/bower_components/jquery/dist/jquery.js:330:5), <anonymous>:4:15)
at fire (https://localhost:3000/bower_components/jquery/dist/jquery.js:3073:30)
at Object.self.add [as done] (https://localhost:3000/bower_components/jquery/dist/jquery.js:3119:7)
at jQuery.fn.ready (https://localhost:3000/bower_components/jquery/dist/jquery.js:3352:25)
at jQuery.fn.init (https://localhost:3000/bower_components/jquery/dist/jquery.js:2794:16)
at jQuery (https://localhost:3000/bower_components/jquery/dist/jquery.js:76:10)
at eval (eval at <anonymous> (https://localhost:3000/bower_components/jquery/dist/jquery.js:330:5), <anonymous>:1:1)
我的代码是highcharts网站上的简单示例:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
});
});
</script>
我还尝试过内线第一行
的版本var chart = new Highcharts.Chart({
当我打印出Highcharts的内容时,它会给我一个正确的对象。 jQuery已加载并正在运行。 在这一点上我还能尝试什么呢?
答案 0 :(得分:8)
您需要在highcharts之前加载JQuery。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
答案 1 :(得分:0)
好的,这个问题实际上非常简单。在早期的代码中有一个脚本标记加载高级图表,它与此行中的注入冲突。
如果您看到此错误,请检查是否已经注入过highcharts。