01.
<?php
02.
include_once
'../jpgraph-3.5.0b1/src/jpgraph.php'
;
03.
include_once
'../jpgraph-3.5.0b1/src/jpgraph_bar.php'
;
04.
include_once
'../jpgraph-3.5.0b1/src/jpgraph_line.php'
;
05.
06.
$objConnect
= mysql_connect(
"localhost"
,
"root"
,
"1234"
)
or
die
(
"Error connect to Database"
);
07.
$objDB
= mysql_select_db(
"db_iservice"
);
08.
mysql_query(
"SET NAMES UTF-8"
);
09.
$strSQL
=
"SELECT * FROM requests WHERE id ='282'"
;
10.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
11.
12.
$datay
=
array
();
13.
$d
=
array
();
14.
while
(
$objResult
= mysql_fetch_array(
$objQuery
)){
15.
$datay
[] =
16.
$objResult
[
"service_code"
];
17.
$d
[] =
$objResult
[
"device_name"
];
18.
}
19.
$graph
=
new
Graph(940.400);
20.
$graph
->SetScale(
"textlin"
);
21.
$graph
->xaxis->SetTickLabels(
$id
);
22.
$graph
->xaxis->SetLabelAngle(90);
23.
24.
$graph
->img->SetAngle(0);
25.
$bplot
=
new
BarPlot(
$datay
);
26.
$bplot
->SetFillColor(
'#EDF5FF'
);
27.
$bplot
->SetWidth(0.6);
28.
$bplot
->SetPattern(PATTERN_CROSS1,
'navy'
);
29.
$graph
->SetMarginColor(
'#EDF5FF'
);
30.
$graph
->SetFrame(true,
'#EDF5FF'
,2);
31.
$graph
->SetColor(
'#EDF5FF'
);
32.
$graph
->Add(
$bplot
);
33.
$graph
->Stroke();
34.
35.
?>