<?php require_once('Connections/rs_Inflowhour.php');
include("../fusioncharts/Charts/FusionCharts.php");
// header('content-type:text/xml');
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_rs_Inflowhour, $rs_Inflowhour);
$query_rsChart = "SELECT plantreal.r_date, format(plantreal.fore, 2) AS forebay, rulecurve.upper, rulecurve.lower
FROM
plantreal
LEFT JOIN rulecurve ON (concat(right(plantreal.r_date,2),'/',mid(plantreal.r_date,6,2)) = rulecurve.r_date)
WHERE
month(plantreal.r_date) BETWEEN '01' AND '12' AND year(plantreal.r_date) = year(curdate()) AND plantreal.r_time = '24:00'
ORDER BY plantreal.r_date";
$rsChart = mysql_query($query_rsChart, $rs_Inflowhour) or die(mysql_error());
$row_rsChart = mysql_fetch_assoc($rsChart);
$totalRows_rsChart = mysql_num_rows($rsChart);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
<SCRIPT LANGUAGE="Javascript" SRC="../FusionCharts/Charts/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<?php do {
$dt[] = $row_rsChart['r_date'];
$dt1[] = $row_rsChart['forebay'];
$dt2[] = $row_rsChart['upper'];
$dt3[] = $row_rsChart['lower'];
} while ($row_rsChart = mysql_fetch_assoc($rsChart));
$data1 = array($dt);
$data2 = array($dt1);
$data3 = array($dt2);
$data4 = array($dt3);
for($i=0;$i<$totalRows_rsChart;$i++)
{
$datas[$i][1] = $dt[$i] ;
$datas[$i][2] = $dt1[$i] ;
$datas[$i][3] = $dt2[$i] ;
$datas[$i][4] = $dt3[$i] ; }
?>
<?php
//$strXML = "chart caption='Monthly Sales Summary' subcaption='For the year 2006' xAxisName='Month' yAxisName='Sales' yAxisMinValue='15000' numberPrefix='$' showValues='0' alternateHGridColor='FCB541' alternateHGridAlpha='20' divLineColor='FCB541' divLineAlpha='50' canvasBorderColor='666666' baseFontColor='666666' lineColor='FCB541'>";
// $strXML = "<chart caption='Sales by Product' numberPrefix='' formatNumberScale='1' rotateValues='1' placeValuesInside='1' decimals='0' >";
$strXML = "<chart palette='2' caption='ข้อมูลระดับน้ำเทียบกับ Upper - Lower Rulecurve' subCaption='ประจำเดือน' showValues='0' divLineDecimalPrecision='1' yAxisName='M.MSL.' limitsDecimalPrecision='1' PYAxisName='Amount' SYAxisName='Quantity' numberPrefix='' formatNumberScale='0' areaOverColumns='0' legendIconScale='2' setAdaptiveYMin='1' >";
//Initialize <categories> element - necessary to generate a multi-series chart
$strCategories = "<categories>";
//Initiate <dataset> elements
$strDataCurr = "<dataset seriesName='ปริมาณน้ำ' color='33CC33' anchorBorderColor='000000' renderAs='Area'>";
$strDataCurr1 = "<dataset seriesName='Upper Rulecurve' color='0000FF' anchorBorderColor='330099' renderAs='Line'>";
$strDataCurr2 = "<dataset seriesName='Lower Rulecurve' color='FF0000' anchorBorderColor='CC0000' renderAs='Line'>";
//Iterate through the data
//Append <category label='...' /> to strCategories
foreach ($datas as $arSubData) {
$strCategories .= "<category label='" . $arSubData[1] . "' />";
//Add <set value='...' /> to both the datasets
$strDataCurr .= "<set value='" . $arSubData[2] . "' />";
$strDataCurr1 .= "<set value='" . $arSubData[3] . "' />";
$strDataCurr2 .= "<set value='" . $arSubData[4] . "' />";
//Close <categories> element }
}
$strCategories .= "</categories>";
//Close <dataset> elements
$strDataCurr .= "</dataset>";
$strDataCurr1 .= "</dataset>";
$strDataCurr2 .= "</dataset>";
//Assemble the entire XML now
$strXML .= $strCategories . $strDataCurr . $strDataCurr1 . $strDataCurr2 . "</chart>";
//echo $strXML;
//Create the chart - Column 2D Chart with data from strXML
echo renderChart("../FusionCharts/Charts/MSCombi2D.swf", "", $strXML, "FactoryDetailed", 800, 550, false, false);
mysql_free_result($rsChart);
?>
ไม่มีความคิดเห็น:
แสดงความคิดเห็น