我正在使用Fusionchartsfree为我的网站创建可视化工具。
我已经调整了示例页面,如下面的代码所示。这在我的xampp上可以100%起作用,但是在上载(托管在hostgator上)时,它无法显示图形。
这是我的代码:
<?php
//We've included ../Includes/FusionCharts_Gen.php, which contains
//FusionCharts PHP Class to help us easily embed charts
//We've also used ../Includes/DBConn.php to easily connect to a database.
include("FusionCharts_Gen.php");
include("DBConn.php");
?>
<HTML>
<HEAD>
<TITLE>
Report Bar Chart
</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="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>
report
<CENTER>
<?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 Database
$link = connectToDB();
# Create pie 3d chart object using FusionCharts PHP Class
$FC = new FusionCharts("Pie3D","650","450");
# Set Relative Path of swf file.
$FC->setSwfPath("FusionCharts/");
//Store chart attributes in a variable for ease of use
$strParam="caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30; showBorder=1;showNames=1;formatNumberScale=0;numberSuffix= Units;decimalPrecision=0";
# Set chart attributes
$FC->setChartParams($strParam);
// Fetch all factory records usins SQL Query
//Store chart data values in 'total' column/field and category names in 'FactoryName'
$strQuery = "select factory_output.FactoryID as factoryid, factory_master.FactoryName as factoryname, sum(factory_output.Quantity) as total from factory_output, factory_master where factory_output.FactoryId=factory_master.FactoryId group by factory_output.FactoryId,factory_master.FactoryName";
$result = mysql_query($strQuery) or die(mysql_error());
//Pass the SQL Query result to the FusionCharts PHP Class function
//along with field/column names that are storing chart values and corresponding category names
//to set chart data from database
if ($result) {
$FC->addDataFromDatabase($result, "total", "FactoryName");
}
mysql_close($link);
# Render the chart
$FC->renderChart();
?>
</CENTER>
</BODY>
</HTML>
请您让我知道我要去哪里了吗?如前所述,这在我的xampp上有效,仅数据库的用户名和密码已更改,但是我没有收到任何mysql登录错误,因此不要以为是。
另外,还有其他任何易于使用的经典且可靠的图形包吗?
谢谢,
瑞安
最佳答案
检查浏览器的控制台日志中是否显示错误。
FusionCharts.js文件或SWF文件可能无法访问。
让我们知道控制台日志中的任何错误。
了解有关调试图表的更多信息-http://docs.fusioncharts.com/charts/contents/?Debug/Basic.html
关于php - FusionCharts图形未显示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8604215/