2012-06-27 59 views
0

你好傢伙我在這個FusionCharts上做了一個評估,我一直在陷入困境。我得到這個錯誤,不知道爲什麼......有人熟悉FusionCharts?FusionCharts - 無法找到容器DOM元素

我只是試圖運行示例

<script src="../js/fusioncharts/FusionCharts.js" type="text/javascript"></script> 

<script type="text/javascript"> 

<!--    

var myChart = new FusionCharts ("../js/fusioncharts/Column3D.swf",     
      "myChartId", "400", "300", "0", "1");  

      myChart.setJSONData({   
      "chart":   
       {     
       "caption" : "Weekly Sales Summary" ,      
       "xAxisName" : "Week",     
       "yAxisName" : "Sales",     
       "numberPrefix" : "$"   
       },   

      "data" :   
      [     
       { "label" : "Week 1", "value" : "14400" },     
       { "label" : "Week 2", "value" : "19600" },     
       { "label" : "Week 3", "value" : "24000" },     
       { "label" : "Week 4", "value" : "15700" }   
      ] 
    }); 

      myChart.render("div_view");   

    // -->   

    </script> 
    <div id="div_view">FusionCharts will load here!</div> 
+0

固定它....

FusionCharts will load here!
必須在JS –

回答

2

固定它.... FusionCharts的將加載在這裏!

有砥前的JS

0

通過融合圖表被加載時,DOM還沒有完全加載。 所以儘量腳本與

$(document).ready(function(){ 

// your code goes here. 
     var myChart = new FusionCharts ("../js/fusioncharts/Column3D.swf",     
     "myChartId", "400", "300", "0", "1");  

     myChart.setJSONData({   
     "chart":   
      {     
      "caption" : "Weekly Sales Summary" ,      
      "xAxisName" : "Week",     
      "yAxisName" : "Sales",     
      "numberPrefix" : "$"   
      },   

     "data" :   
     [     
      { "label" : "Week 1", "value" : "14400" },     
      { "label" : "Week 2", "value" : "19600" },     
      { "label" : "Week 3", "value" : "24000" },     
      { "label" : "Week 4", "value" : "15700" }   
     ] 
}); 

     myChart.render("div_view"); 

}); 

否則。 編寫腳本標籤<div>標籤後

1

在創建FusionCharts的對象的第五個參數是DOM元素在渲染應該做在這裏看到更多的信息

http://www.fusioncharts.com/dev/api/fusioncharts.html

因此任何字符串你因爲DOM元素應設置爲要顯示圖表的DIV的ID,例如:

Fusion圖表對象是這樣創建的:$pie3dChart = new FusionCharts("pie3d", "ex2", "100%", 400, "chart-1", "json", .... 這裏字符串「圖表-1」是DOM Element id,所以你應該在文檔中有一個div,像這樣<div id="chart-1"></div>這將是渲染髮生的地方。