Folder reorganize 1
This commit is contained in:
123
OLD/charts/multi.php
Normal file
123
OLD/charts/multi.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
//We have included ../Includes/FusionCharts.php, which contains functions
|
||||
//to help us easily embed the charts.
|
||||
include("inc/FusionCharts.php");
|
||||
include("config.php");
|
||||
?>
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE> FusionCharts XT - </TITLE>
|
||||
<SCRIPT LANGUAGE="Javascript" SRC="fusioncharts/fusioncharts.js"></SCRIPT>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
<?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();
|
||||
|
||||
|
||||
// SQL query for category labels
|
||||
$strQueryCategories = "select distinct DATE_FORMAT(date,'%c-%d-%Y') as Date FROM trending ORDER by Date DESC LIMIT 96";
|
||||
|
||||
// Query database
|
||||
$resultCategories = mysql_query($strQueryCategories) or die(mysql_error());
|
||||
|
||||
// SQL query for factory output data
|
||||
$strQueryData = "select id, boiler1sf, boiler2sf, boiler3sf, boiler4sf, boiler5sf, boiler6sf, exststmflow1, DATE_FORMAT(date,'%c-%d-%Y') as Date FROM trending ORDER BY Date DESC LIMIT 96";
|
||||
|
||||
// Query database
|
||||
$resultData = mysql_query($strQueryData) or die(mysql_error());
|
||||
|
||||
//We also keep a flag to specify whether we've to animate the chart or not.
|
||||
//If the user is viewing the detailed chart and comes back to this page, he shouldn't
|
||||
//see the animation again.
|
||||
$animateChart = @$_GET['animate'];
|
||||
//Set default value of 1
|
||||
if ($animateChart=="")
|
||||
$animateChart = "1";
|
||||
|
||||
//$strXML will be used to store the entire XML document generated
|
||||
//Generate the chart element
|
||||
$strXML = "<chart legendPostion='' caption='This is a chart' subCaption='This is subtext' xAxisName='Date' yAxisName='PSI' showValues='0' formatNumberScale='0' rotateValues='1' animation=' " . $animateChart . "'>";
|
||||
|
||||
// Build category XML
|
||||
$strXML .= buildCategories ($resultCategories, "Date");
|
||||
|
||||
// Build datasets XML
|
||||
$strXML .= buildDatasets ( $resultData, "boiler1sf", "boiler2sf", "boiler3sf", "boiler4sf", "boiler5sf", "boiler6sf");
|
||||
|
||||
//Finally, close <chart> element
|
||||
$strXML .= "</chart>";
|
||||
|
||||
|
||||
//Create the chart - Pie 3D Chart with data from strXML
|
||||
//echo renderChart("../../FusionCharts/MSLine.swf", "", $strXML, "FactorySum", 700, 400, false, false);
|
||||
echo renderChart("line", "", $strXML, 600, 300, false, false);
|
||||
|
||||
|
||||
// Free database resource
|
||||
mysql_free_result($resultCategories);
|
||||
mysql_free_result($resultData);
|
||||
mysql_close($link);
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Function to build XML for categories
|
||||
* @param $result Database resource
|
||||
* @param $labelField Field name as String that contains value for chart category labels
|
||||
*
|
||||
* @return categories XML node
|
||||
*/
|
||||
function buildCategories ( $result, $labelField ) {
|
||||
$strXML = "";
|
||||
if ($result) {
|
||||
$strXML = "<categories>";
|
||||
while($ors = mysql_fetch_array($result)) {
|
||||
$strXML .= "<category label='" . $ors[$labelField]. "'/>";
|
||||
}
|
||||
$strXML .= "</categories>";
|
||||
}
|
||||
return $strXML;
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* Function to build XML for datesets that would contain chart data
|
||||
* @param $result Database resource. The data should come ordered by a control break
|
||||
field which would require to identify datasets and set its value to
|
||||
dataset's series name
|
||||
* @param $valueField Field name as String that contains value for chart dataplots
|
||||
* @param $controlBreak Field name as String that contains value for chart dataplots
|
||||
*
|
||||
* @return Dataset XML node
|
||||
*/
|
||||
function buildDatasets ($result, $valueField, $controlBreak ) {
|
||||
$strXML = "";
|
||||
if ($result) {
|
||||
|
||||
$controlBreakValue ="";
|
||||
|
||||
while( $ors = mysql_fetch_array($result) ) {
|
||||
|
||||
if( $controlBreakValue != $ors[$controlBreak] ) {
|
||||
$controlBreakValue = $ors[$controlBreak];
|
||||
$strXML .= ( $strXML =="" ? "" : "</dataset>") . ( "<dataset seriesName='" . $controlBreakValue . "'>" ) ;
|
||||
}
|
||||
$strXML .= "<set value='" . $ors[$valueField] . "'/>";
|
||||
|
||||
}
|
||||
$strXML .= "</dataset>";
|
||||
}
|
||||
return $strXML;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
Reference in New Issue
Block a user