dongxichan8627 2015-01-31 06: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-03 23: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 传人记程序做的plc 485从机程序该如何写
  • ¥15 已知手指抓握过程中掌指关节、手指各关节和指尖每一帧的坐标,用贝塞尔曲线可以拟合手指抓握的运动轨迹吗?
  • ¥50 libwebsockets 如何添加其他socket事件回调
  • ¥50 实现画布拖拽算子排布,通过flink实现算子编排计算,请提供思路
  • ¥15 esium自定义材质拉伸问题
  • ¥15 cmake+mingw使用<mysqlx/xdevapi.h>报错
  • ¥15 eNSP中防火墙的使用
  • ¥15 关于#mlnet#的问题:mlnet相关请求(语言-c#)
  • ¥15 lvgl7.11怎么做出文字被选中的效果
  • ¥50 如何快速查看手机目标app的主要服务器ip
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部