<?php
include("config.php");
include (".../jpgraph/jpgraph.php");
include (".../jpgraph/jpgraph_bar.php");
$m = $_POST['month'];
$y = $_POST['year']-(543);
$name=พฤษภาคม;
// ติดต่อ ฐานข้อมูล เลือกข้อมูลขึ้นมาเพื่อแสดงกราฟ
$strSQL = "SELECT o.ot_code as ot_code, Count(t.ot_id) as count_ot_id FROM therapy AS t INNER JOIN ot AS o ON o.ot_id = t.ot_id
WHERE MONTH(the_date) = $m AND YEAR(the_date) = $y GROUP BY o.ot_code";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
// เตรียมข้อมุลที่จะแสดง เพื่อสร้างกราฟ
//$datay=array();
while($objResult = mysql_fetch_array($objQuery))
{
$datay[] = $objResult["count_ot_id"];
$datax[] = $objResult["ot_code"];
}
// Create the graph.
$graph = new Graph(600,400);
$graph->SetScale("textlin");
$graph->SetMarginColor('navy:1.9');
$graph->SetBox();
// Create and add a new text
$txt=new Text('เดือน '.$name);
$txt->SetPos(260,360);
$txt->SetColor('darkred');
$txt->SetFont(FF_ANGSA,FS_BOLD,15);
$txt->SetBox('yellow','navy','[email protected]');
$graph->AddText($txt);
// Setup the titles
$graph->title->Set('กราฟแสดงจำนวนผู้ป่วยต่อนักกิจกรรมบำบัด');
$graph->xaxis->title->Set('OT');
$graph->yaxis->title->Set('จำนวนผู้ป่วย');
//$graph->yaxis->title->Set(10,20);
$graph->title->SetFont(FF_ANGSA,FS_BOLD,16);
$graph->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,16);
$graph->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,16);
$graph->title->Set('กราฟแสดงจำนวนผู้ป่วยต่อนักกิจกรรมบำบัด');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->SetTitleBackground('lightblue:1.3',TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL);
$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'lightblue','blue');
//Setup X-scale
//$graph->xaxis->SetTextTickInterval(10);
//$graph->xaxis->SetTickLabels($datax);
//$graph->xtick_factor = 1;
//$graph->xaxis->SetLabelAngle(30);
//$graph->xaxis->SetTickLabels(array('OT1','OT2','OT3','OT6','OT7'));
$graph->xaxis->SetTickLabels($datax);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkorange');
$bplot->SetWidth(0.6);
$bplot->SetPattern(PATTERN_CROSS1,'navy');
$graph->Add($bplot);
$graph->Stroke();
?>