Javascript 致命错误:调用未定义的函数FusionCharts()

Javascript 致命错误:调用未定义的函数FusionCharts(),javascript,php,charts,Javascript,Php,Charts,我想在我的项目中使用Fusion图表,我曾经在以下链接中编写代码: 问题是当我运行代码时,图表不显示。浏览器会一直显示此错误: Fatal error: Call to undefined function FusionCharts() in C:\xampp\htdocs\Audit_Project\pie_chart.php on line 15 我怎样才能解决这个问题 我的代码: <?php include("PDF/fusioncharts.php"); //

我想在我的项目中使用Fusion图表,我曾经在以下链接中编写代码: 问题是当我运行代码时,图表不显示。浏览器会一直显示此错误:

Fatal error: Call to undefined function FusionCharts() in C:\xampp\htdocs\Audit_Project\pie_chart.php on line 15
我怎样才能解决这个问题

我的代码:

<?php

    include("PDF/fusioncharts.php");
    // Create the chart - Column 2D Chart with data given in constructor parameter 
    // Syntax for the constructor - 

         new FusionCharts("type of chart", 
            "unique chart id", 
            "width of chart", 
            "height of chart", 
            "div id to render the chart", 
            "type of data", 
            "actual data");

            $Chart = new FusionCharts("column2d", "ex1" , 600, 400, "chart-1", "json", '{  
           "chart":{  
              "caption":"Harry\'s SuperMart",
              "subCaption":"Top 5 stores in last month by revenue",
              "numberPrefix":"$",
              "theme":"ocean"
           },
           "data":[  
              {  
                 "label":"Bakersfield Central",
                 "value":"880000"
              },
              {  
                 "label":"Garden Groove harbour",
                 "value":"730000"
              },
              {  
                 "label":"Los Angeles Topanga",
                 "value":"590000"
              },
              {  
                 "label":"Compton-Rancho Dom",
                 "value":"520000"
              },
              {  
                 "label":"Daly City Serramonte",
                 "value":"330000"
              }
           ]
        }');
    // Render the chart
    $Chart->render();
?>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="UTF-8">
            <title>Home</title>
            <script type="text/javascript" src="fusioncharts.js"></script>
            <script type="text/javascript" src="fusioncharts.theme.ocean.js"></script>
    </head>
    <body></body>
</html>

正如我在GitHub上看到的,它只有一个名为FusionCharts的类,它不是一个函数$图表=新的FusionCharts()

我认为您需要注释掉代码的以下部分:

new FusionCharts("type of chart", 
            "unique chart id", 
            "width of chart", 
            "height of chart", 
            "div id to render the chart", 
            "type of data", 
            "actual data");

或者您可以参考本页了解正确的工作代码:

我错过了代码中的“新”部分。现在没有显示错误。但是,也没有显示任何图表。它是空的。您是否将所有内容传递给它的_构造,并调用render方法$图表->渲染();对我有一个名为(pie_chart.php)的php页面,其中包含了fusioncharts.php和前面提到的js库。您提供了有效的数据吗?你能展示你的完整代码吗?你确定js文件的路径是正确的吗?它们应该和php脚本在同一个文件夹中,这样我就可以使用它了。你可以从这里拿到。