fusionchart不显示图形

时间:2015-02-18 23:45:28

标签: php mysql dreamweaver fusioncharts

我想知道为什么我的图表不起作用。我完全按照描述做了。我试图将“日期”与“peak_generation”联系起来。但是当代码运行时,它会给出“无数据显示”消息。可以做些什么来解决它

<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php,      which contains
//functions to help us easily embed the charts and connect to a database.
include("Includes/FusionCharts.php");
include("Includes/DBConn.php");
?>
<HTML>
<HEAD>
<TITLE>
FusionCharts Free - Database Example
</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="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

//Iterate through each factory
//if ($result) {
    //
        //Now create a query to get details for this output
        $strQuery = "select SUM(peak_generation) as TotOutput, date as DAYS FROM daily_output GROUP BY date";
        $result = mysql_query($strQuery) or die(mysql_error()); 

        $strXML = "<chart caption='Annual Revenue - last 3 years' numberPrefix='$'>";
        while($row = mysql_fetch_array($result)) {
        //Generate <set name='..' value='..' />        
        $strXML .= "<set label = '".$row['DAYS']."' value = '".$row['TotOutput']."' />";
        }
        //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);
        echo renderChart("charts/FCF_Column3D.swf", "", $strXML, "annual_revenue", 600, 300);


        //free the resultset
        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 个答案:

答案 0 :(得分:0)

你能分享$ strXML的价值吗?

另请注意,如果使用FusionCharts Free,请将<chart> </chart>修改为<graph></graph>

相关问题