PHP histogram generate class Code//This is a perfect PHP histogram generated class code, you can generate beautiful and practical bar chart
PHP Tutorial histogram generate class Code
This is a perfect PHP histogram generated class code, you can generate beautiful and practical bar chart
function CreateImage ($data, $twidth, $tspace, $height) {
$dataname = Array ();
$datavalue = Array ();
$i = 0;
$j = 0;
$k = 0;
$num = sizeof ($DATA);
foreach ($data as $key = = $val) {
$dataname [] = $key;
$datavalue [] = $val;
}
$maxnum = max ($data);
$width = ($twidth + $tspace) * $num + 4;//image ' s width
$im = imagecreate ($width + +, $height +20);
$linecolor = Imagecolorallocate ($im, 12,12,12);
$bgcolor = Imagecolorallocate ($im, 235,233,233);
$tcolor = Imagecolorallocate ($im, 123,200,56);
Imagefill ($im, 0,0, $bgcolor);
Imageline ($im, 0, $height-2, $linecolor);
Imageline ($im, $height-2, $width + 30-2, $height-2, $linecolor);
while ($i < $num) {
Imagefilledrectangle ($im, $i * ($tspace + $twidth) +, $height-$datavalue [$i], $i * ($tspace + $twidth) + + + $twidth, $height -3, $tcolor);
Imagestringup ($im, 4, $i * ($tspace + $twidth) + $twidth/2 +, $height -10, $dataname [$i]. " (". $datavalue [$i].") ", $linecolor);
$i + +;
}
while ($j <= (500/10)) {
Imagestringup ($im, 4, 2, $height-$j * + ten, $j *, $linecolor);
$j = $j + 10;
}
while ($k <= (500/10)) {
if ($k! = 0)
Imageline ($im, $height-$k *, $height-$k *, $linecolor);
$k = $k + 10;
}
Imagepng ($im);
}
Call Method:
header ("Content-type:image/png");
$data = Array ("Yahoo" + +, "google" = 260, "Microsoft" + +, "IBM" = 290, "Sun system", "inter" = > 260);
CreateImage ($data, 38,25,460);
http://www.bkjia.com/PHPjc/633041.html www.bkjia.com true http://www.bkjia.com/PHPjc/633041.html techarticle PHP Histogram generated class code//This is a perfect PHP histogram generated class code, you can generate beautiful and practical histogram PHP tutorial histogram generated class code//This is a perfect PHP columnar ...