2014-11-08 109 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

相关问题