01.
<?php
02.
include
(
"config.php"
);
03.
include
(
".../jpgraph/jpgraph.php"
);
04.
include
(
".../jpgraph/jpgraph_bar.php"
);
05.
06.
$m
=
$_POST
[
'month'
];
07.
$y
=
$_POST
[
'year'
]-(543);
08.
$name
=พฤษภาคม;
09.
10.
11.
$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
12.
WHERE MONTH(the_date) =
$m
AND YEAR(the_date) =
$y
GROUP BY o.ot_code";
13.
14.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
15.
16.
17.
18.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
19.
{
20.
$datay
[] =
$objResult
[
"count_ot_id"
];
21.
$datax
[] =
$objResult
[
"ot_code"
];
22.
}
23.
24.
25.
$graph
=
new
Graph(600,400);
26.
27.
$graph
->SetScale(
"textlin"
);
28.
29.
$graph
->SetMarginColor(
'navy:1.9'
);
30.
$graph
->SetBox();
31.
32.
33.
$txt
=
new
Text(
'เดือน '
.
$name
);
34.
$txt
->SetPos(260,360);
35.
$txt
->SetColor(
'darkred'
);
36.
$txt
->SetFont(FF_ANGSA,FS_BOLD,15);
37.
$txt
->SetBox(
'yellow'
,
'navy'
,
'gray@0.5'
);
38.
$graph
->AddText(
$txt
);
39.
40.
41.
$graph
->title->Set(
'กราฟแสดงจำนวนผู้ป่วยต่อนักกิจกรรมบำบัด'
);
42.
$graph
->xaxis->title->Set(
'OT'
);
43.
$graph
->yaxis->title->Set(
'จำนวนผู้ป่วย'
);
44.
45.
46.
$graph
->title->SetFont(FF_ANGSA,FS_BOLD,16);
47.
$graph
->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,16);
48.
$graph
->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,16);
49.
50.
$graph
->title->Set(
'กราฟแสดงจำนวนผู้ป่วยต่อนักกิจกรรมบำบัด'
);
51.
$graph
->title->SetFont(FF_ANGSA,FS_BOLD,18);
52.
53.
$graph
->SetTitleBackground(
'lightblue:1.3'
,TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL);
54.
$graph
->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,
'lightblue'
,
'blue'
);
55.
56.
57.
58.
59.
60.
61.
62.
63.
$graph
->xaxis->SetTickLabels(
$datax
);
64.
65.
$bplot
=
new
BarPlot(
$datay
);
66.
$bplot
->SetFillColor(
'darkorange'
);
67.
$bplot
->SetWidth(0.6);
68.
69.
$bplot
->SetPattern(PATTERN_CROSS1,
'navy'
);
70.
$graph
->Add(
$bplot
);
71.
$graph
->Stroke();
72.
?>