本文整理汇总了PHP中FusionCharts::addDataFromDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP FusionCharts::addDataFromDatabase方法的具体用法?PHP FusionCharts::addDataFromDatabase怎么用?PHP FusionCharts::addDataFromDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FusionCharts
的用法示例。
在下文中一共展示了FusionCharts::addDataFromDatabase方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FusionCharts
# Create a column 3d chart object
$FC = new FusionCharts("Column2D", "600", "300");
# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");
// Store Chart attributes in a variable
$strParam = "caption={$FactoryName} Output;subcaption=(In Units);xAxisName=Date; formatNumberScale=0;decimalPrecision=0;rotateNames=1;showValues=0";
# Set chart attributes
$FC->setChartParams($strParam);
// Connet to the DataBase
$link = connectToDB();
//Now, we get the data for that factory
//storing chart values in 'Quantity' column and category names in 'DDate'
$strQuery = "select Quantity, DATE_FORMAT(DatePro,'%e-%b-%Y') as DDate from Factory_Output where FactoryId=" . $FactoryId;
$result = mysql_query($strQuery) or die(mysql_error());
//Pass the SQL query result to the FusionCharts PHP Class' function
//that will extract data from database and add to the chart.
if ($result) {
$FC->addDataFromDatabase($result, "Quantity", "DDate");
}
mysql_close($link);
//Create the chart
$FC->renderChart();
?>
<BR>
<a href='Default.php'>Back to Summary</a>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>« Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>
示例2: connectToDB
include "../Includes/FusionCharts_Gen.php";
//This page generates the XML data for the Pie Chart contained in
//Default.php.
//For the sake of ease, we've used an MySQL databases containing two
//tables..
//Connect to the Database
$link = connectToDB();
# Create a pie 3d chart object
$FC = new FusionCharts("Pie3D", "650", "450");
# Set Relative Path of swf file.
$FC->setSWFPath("../../FusionCharts/");
# Define chart attributes
$strParam = "caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30;showBorder=1;numberSuffix= Units";
#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 a.FactoryID, b.FactoryName, sum(a.Quantity) as total from Factory_output a, Factory_Master b where a.FactoryId=b.FactoryId group by a.FactoryId,b.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);
//Set Proper output content-type
header('Content-type: text/xml');
//Just write out the XML data
//NOTE THAT THIS PAGE DOESN'T CONTAIN ANY HTML TAG, WHATSOEVER
print $FC->getXML();
示例3: FusionCharts
# Create column 2d chart object
$FC = new FusionCharts("Column2D", "500", "400");
# Set Chart attributes
$FC->setChartParams("caption=Monthly Sales Summary;subcaption=For the year 2008;");
$FC->setChartParams("xAxisName=Month;yAxisName=Sales;numberPrefix=\$;showNames=1;");
$FC->setChartParams("showValues=0;showColumnShadow=1;animation=1;");
$FC->setChartParams("baseFontColor=666666;lineColor=FF5904;lineAlpha=85;");
$FC->setChartParams("valuePadding=10;labelDisplay=rotate;useRoundEdges=1");
//Connect to the DB
$link = connectToDB('sales');
// Fetch all factory records
$strQuery = "select * from monthly_utf8";
$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, "amount", "month_name");
}
//free the resultset
mysql_free_result($result);
// close database
mysql_close($link);
# define and apply style
$FC->defineStyle("myCaptionFont", "Font", "size=12");
$FC->applyStyle("DATALABELS", "myCaptionFont");
//Set Proper output content-type
header('Content-type: text/xml');
//Just write out the XML data
//NOTE THAT THIS PAGE DOESN'T CONTAIN ANY HTML TAG, WHATSOEVER
print $FC->getXML();
示例4: FusionCharts
<?php
/**
* Created by PhpStorm.
* User: Allan Wiz
* Date: 4/17/15
* Time: 4:48 PM
*/
include '../classes/aardb_conn.php';
include '../charts/JSClass/FusionCharts_Gen.php';
global $session, $database;
global $conn;
$FC = new FusionCharts("FC_Line.swf", "900", "450");
$FC->setDataBaseType("Oracle");
$FC->setSwfPath("../Charts/");
$strParam = "caption=INTEREST VIEW REPORT (for the last 14 days);subCaption=BY APPLICABLE DATE ; showNames='1';pieSliceDepth=30;showBorder=1;numberSuffix= %; formatNumberScale='0'; xAxisName=Date; pYAxisName=Net Asset Value;sYAxisName=BalancedFund";
$FC->setChartParams($strParam);
$start = date("d/M/Y", strtotime('-50 days'));
$today = date("d/M/Y");
$sql = "SELECT I_RATES.RATE_ID, I_RATES.RATE_DATE AS DATEY, I_RATES.RATE AS RATE, SECURITIES.DESCRIPT AS DESCRIPTION FROM I_RATES INNER JOIN\r SECURITIES ON I_RATES.SECURITY_CODE = SECURITIES.SECURITY_CODE WHERE I_RATES.CONFIRMD = 1 AND I_RATES.RATE_DATE BETWEEN '{$start}' AND '{$today}' ORDER BY I_RATES.RATE_DATE";
$result = oci_parse($conn, $sql) or die("");
oci_execute($result);
if ($result) {
//$FC->addCategoryFromDatabase($result,"DESCRIPTION");
$FC->addDataFromDatabase($result, "RATE", "DATEY");
}
print $FC->getXML();
示例5: sum
$FC->setChartParams($strParam);
# Fetch all factory records creating SQL query
$strQuery = "select a.FactoryID, b.FactoryName, sum(a.Quantity) as total from Factory_output a, Factory_Master b where a.FactoryId=b.FactoryId group by a.FactoryId,b.FactoryName";
$result = mysql_query($strQuery) or die(mysql_error());
#Pass the SQL query result and Drill-Down link format to PHP Class Function
# this function will automatically add chart data from database
/*
The last parameter passed i.e. "Detailed.php?FactoryId=##FactoryID##"
drill down link from the current chart
Here, the link redirects to another PHP file Detailed.php
with a query string variable -FactoryId
whose value would be taken from the Query result created above.
Any thing placed between ## and ## will be regarded
as a field/column name in the SQL query result.
value from that column will be assingned as the query variable's value
Hence, for each dataplot in the chart the resultant query variable's value
will be different
*/
if ($result) {
$FC->addDataFromDatabase($result, "total", "FactoryName", "", "Detailed.php?FactoryId=##FactoryID##");
}
mysql_close($link);
# Create the chart
$FC->renderChart();
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>« Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>
示例6: sum
# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");
// Store Chart attributes in a variable
$strParam="caption=Industrie rapport de la production;subCaption=par quantité; decimalPrecision=0;showNames=1;numberSuffix= Units;pieSliceDepth=30";
# Set chart attributes
$FC->setChartParams($strParam);
// Fetch all factory records
$strQuery = "select a.FactoryId, a.FactoryName, sum(b.Quantity) as TotOutput from French_Factory_Master a,Factory_Output b where a.FactoryId=b.FactoryId group by a.FactoryId, a.FactoryName";
$result = mysql_query($strQuery) or die(mysql_error());
//Iterate through each factory
if ($result) {
// Convert Result set to FusionCharts Data
$FC->addDataFromDatabase($result, "TotOutput", "FactoryName");
}
//free the resultset
mysql_free_result($result);
mysql_close($link);
//Set Proper output content-type and charset
header('Content-type: text/xml;charset=UTF-8');
//Just write out the XML data
//NOTE THAT THIS PAGE DOESN'T CONTAIN ANY HTML TAG, WHATSOEVER
?>
<?xml version='1.0' encoding='UTF-8'?><?php echo $FC->getXML(); ?>
示例7: FusionCharts
<?php
include '../classes/aardb_conn.php';
include '../charts/JSClass/FusionCharts_Gen.php';
global $session, $database;
global $conn;
$FC = new FusionCharts("300", "350");
$FC->setDataBaseType("Oracle");
$FC->setSwfPath("../Charts/");
$strParam = "caption=NET ASSET VALUE REPORT;subCaption=BY DATE; showNames='1';pieSliceDepth=30;showBorder=1;numberSuffix= NAV; formatNumberScale='0'; xAxisName=Date; yAxisName=Net Asset Value";
$FC->setChartParams($strParam);
$start = date("d/M/Y", strtotime('-7 days'));
$today = date("d/M/Y");
$sql = "SELECT NAVS.NAV_ID, NAVS.NAV_DATE as NAV_DATE, NAVS.SECURITY_CODE, NAVS.AMOUNT as AMOUNT, SECURITIES.DESCRIPT as DESCRIPTION\r FROM NAVS INNER JOIN SECURITIES ON NAVS.SECURITY_CODE = SECURITIES.SECURITY_CODE\r WHERE NAVS.CONFIRMD = 1 AND NAVS.NAV_DATE BETWEEN '{$start}' AND '{$today}' ORDER BY NAVS.NAV_DATE ASC";
$result = oci_parse($conn, $sql) or die("");
oci_execute($result);
if ($result) {
$FC->addDataFromDatabase($result, "AMOUNT", "NAV_DATE");
}
print $FC->getXML();