| Скажите, почему в результате работы этого скрипта столбцы на графике отображаются не полностю. Т.е. прямоугольники рисуются с черным контуром, но не по всему периметру.
<?
function DrawGraphic($w,$h,$x,$y)
{
$max_y = max($y);
$power = 0;
while($max_y > 10)
{
$max_y/=10;
$power++;
}
$max_y = ceil($max_y);
$max_x = count($x)-1;
$image = ImageCreate($w,$h);
$c_whtie = imageColorAllocate($image,255,255,255);
$c_black = imageColorAllocate($image,0,0,0);
$c_gray = imageColorAllocate($image,200,200,200);
imageRectangle($image,0,0,$w-1,$h-1,$c_gray);
imageRectangle($image,30,10,$w-11,$h-31,$c_gray);
$step_y = ($h-41)/$max_y;
for($i=0;$i<$max_y;$i++)
{
$size = imageTTFBBox(8,0,"tahoma.ttf",$i*pow(10,$power));
imageTTFText($image,8,0,20-$size[2]-$size[0],$h-31-$i*$step_y+(($size[1]-$size[7])/2),$c_gray,"tahoma.ttf",$i*pow(10,$power));
imageLine($image,30,$h-31-$i*$step_y,$w-11,$h-31-$i*$step_y,$c_gray);
}
$step_x = ($w-41)/$max_x;
for($i=0;$i<$max_x;$i++)
{
imageLine($image,30+$i*$step_x,10,30+$i*$step_x,$h-31,$c_gray);
imageFilledRectangle($image,30+$i*$step_x,$h-31-($y[$i]/pow(10,$power)*$step_y),30+$i*$step_x+$step_x,$h-31,$c_gray);
imageRectangle($image,30+$i*$step_x,$h-31-($y[$i]/pow(10,$power)*$step_y),30+$i*$step_x+$step_x,$h-31,$c_black);
$t_w = imageTTFBBox(8,0,"tahoma.ttf",$x[$i]);
imageTTFText($image,8,0,$i*$step_x+30-(($t_w[2]-$t_w[0])/2),$h-17,$c_gray,"tahoma.ttf",$x[$i]);
}
header("Content-type: image/gif");
imageGif($image);
imageDestroy($image);
}
$y = array(rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand(),rand());
$x = array("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24");
DrawGraphic(400,300,$x,$y);
?>
|
| |