график fusioncharts не отображается - PullRequest
0 голосов
/ 22 декабря 2011

Я использую fusionchartsfree для создания инструментов визуализации для моего сайта.

Я настроил образец страницы, как показано ниже. на моем xampp это работает на 100%, но при загрузке (размещенной на hostgator) не удается отобразить график.

Вот мой код:

<?php
//We've included ../Includes/FusionCharts_Gen.php, which contains
//FusionCharts PHP Class to help us easily embed charts 
//We've also used ../Includes/DBConn.php to easily connect to a database.
include("FusionCharts_Gen.php");
include("DBConn.php");

?>
<HTML>
<HEAD>
    <TITLE>
    Report Bar Chart
    </TITLE>
    <?php
    //You need to include the following JS file, if you intend to embed the chart using JavaScript.
    //Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer
    //When you make your own charts, make sure that the path to this JS file is correct. Else, you would get JavaScript errors.
    ?>  
    <SCRIPT LANGUAGE="Javascript" SRC="FusionCharts.js"></SCRIPT>
    <style type="text/css">
    <!--
    body {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 12px;
    }
    .text{
        font-family: Arial, Helvetica, sans-serif;
        font-size: 12px;
    }
    -->
    </style>
</HEAD>
<BODY>
report
<CENTER>


<?php
    //In this example, we show how to connect FusionCharts to a database.
    //For the sake of ease, we've used an MySQL databases containing two
    //tables.

    // Connect to the Database
    $link = connectToDB();

    # Create pie 3d chart object using FusionCharts PHP Class
    $FC = new FusionCharts("Pie3D","650","450"); 

    # Set Relative Path of swf file.
    $FC->setSwfPath("FusionCharts/");

    //Store chart attributes in a variable for ease of use
    $strParam="caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30; showBorder=1;showNames=1;formatNumberScale=0;numberSuffix= Units;decimalPrecision=0";

    #  Set chart attributes
    $FC->setChartParams($strParam);


    // Fetch all factory records usins SQL Query
    //Store chart data values in 'total' column/field and category names in 'FactoryName'
    $strQuery = "select factory_output.FactoryID as factoryid, factory_master.FactoryName as factoryname, sum(factory_output.Quantity) as total from factory_output, factory_master where factory_output.FactoryId=factory_master.FactoryId group by factory_output.FactoryId,factory_master.FactoryName";
    $result = mysql_query($strQuery) or die(mysql_error());

    //Pass the SQL Query result to the FusionCharts PHP Class function 
    //along with field/column names that are storing chart values and corresponding category names
    //to set chart data from database
    if ($result) {
        $FC->addDataFromDatabase($result, "total", "FactoryName");
    }
    mysql_close($link);

    # Render the chart
    $FC->renderChart();
?>
</CENTER>
</BODY>
</HTML>

Пожалуйста, дайте мне знать, где я ошибаюсь? Как уже упоминалось, это работает на моем xampp, только имя пользователя и пароль были изменены для базы данных, однако я не получаю никаких ошибок входа в MySQL, поэтому не думаю, что это так.

В качестве альтернативы есть другие простые в использовании графические пакеты, которые являются стильными и надежными?

Спасибо, Райан

1 Ответ

2 голосов
/ 22 декабря 2011

Проверьте, не отображаются ли в журнале консоли браузера ошибки.

Либо файл FusionCharts.js, либо SWF-файл могут быть недоступны.

Сообщите нам о любых ошибках в журнале консоли.

Узнайте больше об отладке ваших графиков - http://docs.fusioncharts.com/charts/contents/?Debug/Basic.html

...