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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?