2014-09-23 237 views
0

我想highcharts添加到Magento的,但我得到以下錯誤Magento的:類型錯誤:N是不是一個函數

TypeError: N is not a function (highcharts.js line 192) 

我local.xml中

<adminhtml_mymodule_show> 
    <reference name="head"> 
     <action method="addJs"><file>mymodule/js/highcharts.js</file></action> 
     <action method="addJs"><file>mymodule/js/my_charts.js</file></action> 
    </reference> 
</adminhtml_mymodule_show> 

my_charts.js

document.observe("dom:loaded", function() { 
    var chart = new Highcharts.Chart({ 

     chart: { 
      renderTo: 'container', 
      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]}] 
    }); 
}); 

我的視圖文件

<div class="entry-edit"> 
    <div class="entry-edit-head"> 
     <h4 class="icon-head head-customer-view"> 
      <?php echo $this->__('Test header') ?></h4> 
    </div> 
    <h1><?php echo $this->test; ?></h1> 

    <div id="container" style="width:100%; height:400px;"></div> 
</div> 

我檢查了Firebug,這些文件被添加到頭標籤內。我嘗試添加prototype-adapter.js或使用獨立框架,但它不起作用 - 我每次都從標題中獲取錯誤。

使用magento 1.9和高圖4.0.4。

感謝您的任何幫助

+0

與jQuery和prototype.js衝突? – HMR 2014-09-24 00:10:22

+0

您是否能夠將它重新創建爲現場演示,並與magento分離? – 2014-09-24 10:55:52

回答

1

Javascript無法識別highchart.js中的N.可能有外部js需要與highchart.js一起加載。

確保jQuery在highchart.js之前加載。

相關問題