2016-03-06 189 views
0

我想爲我的項目使用Fusion Charts,我已經習慣在以下鏈接中編碼:http://www.fusioncharts.com/php-charts/ 問題是當我運行代碼時圖表不顯示。瀏覽器不斷顯示此錯誤:致命錯誤:調用未定義的函數FusionCharts()

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> 

回答

0

正如我在GitHub上看到的,它只有一個類叫FusionCharts的,至極不是一個函數。 $ chart = new FusionCharts();

+0

我在代碼中錯過了「新」 。現在不顯示錯誤。但是,也沒有顯示圖表。它是空白的。 –

+0

您是否將所有內容都傳遞給其__construct,並調用渲染方法? $ chart->渲染(); – Isty001

+0

是的。我有一個名爲(pie_chart.php)的PHP頁面,其中包含fusioncharts.php和提到的js庫。 –

相關問題