dongxichan8627 2015-01-31 14:13
浏览 50
已采纳

Fusionchart不会从数据库mysql中显示

I wanted to know why my chart is not working. I have included the FusionCharts.php and other necessary files in the project, and using the code below. The page comes up on my browser, but rather than displaying the chart it gives a No data to dispay error. What could be the problem? Regards

    <?php
    //We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains

    include("Includes/FusionCharts.php");
    include("Includes/DBConn.php");
    ?>
    <HTML>
    <HEAD>
        <TITLE>
        FusionCharts Free - Database Example
        </TITLE>

        <SCRIPT LANGUAGE="Javascript" SRC="js/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>

    <CENTER>
    <h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> -Database and Drill-Down Example</h2>


    <?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 DB
        $link = connectToDB();

// Fetch all factory records

        $strQuery = "select SUM(quantity) AS SUM, YEAR(datePro) AS YEAR FROM factory_output GROUP BY YEAR(datePro ) ";
        $result = mysql_query($strQuery) or die(mysql_error());

    //$strXML = "<graph caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' showNames='1' formatNumberScale='0' numberSuffix=' Units' decimalPrecision='0'>";

        $strXML = "<chart caption='Annual Revenue - last 3 years' numberPrefix='$'>";

        //Iterate through each factory

            while ($ors = mysql_fetch_array($result)){

        //Generate <set name='..' value='..' />  
        $strXML .= "<set label ='" . $ors['YEAR'] . "' value='" . $ors['SUM'] . "' />";
                }
//Finally, close <graph> element

        $strXML .= "</chart>";

//Create the chart - Pie 3D Chart with data from $strXML

    echo renderChart("charts/FCF_Column3D.swf", "", $strXML, "FactorySum", 650, 450);

        mysql_free_result($result);



        mysql_close($link);




    ?>
    <BR><BR>
    <a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
    <H5 ><a href='../default.htm'>&laquo; Back to list of examples</a></h5>
    </CENTER>
    </BODY>
    </HTML>
  • 写回答

1条回答 默认 最新

  • dongwen7371 2015-02-04 07:03
    关注

    There is no issue in the code and it should work fine. But can you generate the XML data and check if the returned XML format is correct as per the chart rendered?

    It could be the following scenarios why the error message is appearing instead of the chart:

    • Your XML data doesn't contain any data that could be plotted by FusionCharts XT. In this case, your XML just contains the chart or dataset tags without any data between them.
    • You might be rendering a single-series chart and providing data in multi-series format or vice-versa. In this case too, you'll get a "No data to display" message.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM