01.
<?
02.
header(
"Content-type: image/png"
);
03.
04.
$data
[1]=
"30"
;
05.
$data
[2]=
"40"
;
06.
$data
[3]=
"50"
;
07.
$data
[4]=
"60"
;
08.
$data
[5]=
"70"
;
09.
$data
[6]=
"80"
;
10.
$data
[7]=
"90"
;
11.
$data
[8]=
"100"
;
12.
$img
= ImageCreate(500, 310);
13.
ImageColorAllocate(
$img
, 255, 255, 255);
14.
15.
16.
$line
= ImageColorAllocate(
$img
,176, 208, 210);
17.
$dataFill
= ImageColorAllocate(
$img
, 122, 176, 180);
18.
$black
= ImageColorAllocate(
$img
, 87, 32, 324);
19.
20.
21.
ImageLine(
$img
, 50, 50, 50, 50,
$line
);
22.
23.
$bartick
= 20;
24.
$barspace
= 30;
25.
$barmax
= 400;
26.
$baseX
= 50;
27.
$baseY
= 30;
28.
29.
30.
for
(
$i
=1;
$i
<=
count
(
$data
);
$i
++) {
31.
32.
$percent
[
$i
]=
$data
[
$i
];
33.
$data
[
$i
]=
$data
[
$i
]*
$barmax
/100;
34.
35.
36.
37.
$setBar
[
$i
] =
array
(
$baseX
,
$baseY
,
38.
(
$baseX
+
$barmax
),
$baseY
,
39.
(
$baseX
+
$barmax
), (
$baseY
+
$bartick
),
40.
$baseX
, (
$baseY
+
$bartick
));
41.
42.
ImagePolygon(
$img
,
$setBar
[
$i
], 4,
$line
);
43.
44.
ImageFilledRectangle(
$img
,
$baseX
,
$baseY
, (
$data
[
$i
]+50), (
$baseY
+
$bartick
),
$dataFill
);
45.
46.
ImageString(
$img
, 3, (
$baseX
- 10),
$baseY
+ 5,
$i
,
$black
);
47.
ImageString(
$img
, 3, (
$data
[
$i
] + 55),
$baseY
+ 5,
48.
number_format(
$percent
[
$i
]) .
"%"
,
$black
);
49.
50.
$baseY
+=
$barspace
;
51.
}
52.
53.
ImagePNG(
$img
);
54.
ImageDestroy(
$img
);
55.
?>