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

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.
    点赞 打赏 评论

相关推荐 更多相似问题