1

大家好,我正在对这个 FusionCharts 进行评估,但我一直遇到障碍。我收到这个错误,不知道为什么……有熟悉 FusionCharts 的人吗?

我只是想运行这个例子

<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> 
4

3 回答 3

2

已修复....FusionCharts 将在此处加载!

必须在 JS 之前

于 2012-06-27T18:53:48.747 回答
2

创建 FusionCharts 对象时,第五个参数是应该完成渲染的 DOM 元素,请参阅此处了解更多信息

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

因此,您作为 DOM 元素拥有的任何字符串都应设置为您希望在其中显示图表的 DIV 的 id,例如:

Fusion 图表对象是这样创建的:$pie3dChart = new FusionCharts("pie3d", "ex2", "100%", 400, "chart-1", "json", .... 这里的字符串“ chart-1 ”是 DOM 元素 id,所以你应该在文档中有一个像这样的 div,<div id="chart-1"></div>这将是渲染发生的地方。

于 2017-06-23T07:48:44.483 回答
1

在加载融合图表时,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>标记

于 2013-04-29T10:56:12.483 回答