2014-11-08 111 views
3

時當我嘗試使用簡單highcharts例子不確定是不是一個函數,我得到的錯誤:遺漏的類型錯誤:使用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

你可以複製你的exampel作爲現場演示嗎? – 2014-11-10 11:26:20

回答

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> 
+0

如果你在命令行運行'/ usr/local/bin/phantomjs /opt/html/paradox/protected/extensions/highcharts/exporting-server/phantomjs/highcharts-convert.js -infile protected/extensions/highcharts/exporting -server/php/php-batik/temp/13059.json -outfile images/13059.png -constr圖表 ' – shorif2000 2015-10-14 15:25:02

0

好的,這個問題其實很簡單。在早期的代碼中有一個腳本標籤加載了highcharts,並且與此行中的注入衝突。

如果您看到此錯誤,請檢查highcharts是否已被注入。

+0

在本網站上有點傳統,接受回答問題的人的回答,而不是僅僅自己重複回答。 – 2014-11-11 01:54:29

+0

@ doogabides你指的是誰的答案?你的回答不正確。注意在我的問題中,我正在加載jQuery上面的高層圖。問題與加載高圖兩次有關。 – jokomo 2014-11-19 03:16:45

+0

很高興你發現了這個問題,但只要jQuery是第一個,你就可以不止一次加載高圖。 – 2014-11-19 04:05:52

相關問題