麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
一个动态生成的条型图片
悬赏分:20 - 2007年08月22日

<?
//设置图片基本属性
$GraphWidth = 400;
$GraphHeight = 200;
$GraphScale = 2;
$GraphFont = 5;
$GraphData = array("99","75","15","66","22");
$GraphLabel = array("Beef","Chicken","Pork","Lamb","Lobster");

//create image
$image = imagecreate($GraphWidth,$GraphHeight);

//allocate colors
$colorBody = imagecolorallocate($image,111,111,111);
$colorGrid = imagecolorallocate($image,222,222,222);
$colorBar = imagecolorallocate($image,123,123,123);
$colorText = imagecolorallocate($image,32,121,42);

//fill background
imagefill($image,0,0,$colorBody);

//draw vertical grid line
$GridLabelWidth = imagefontwidth($GraphFont) * 3 + 1;
imageline($image,$GridLabelWidth,0,$GridLabelWidth,$GraphHeight-1,$colorGrid);

//draw horizontal grid lines
for($index = 0 ; $index < $GraphHeight ; $index += $GrapgHeight / 10)
{
imagedashedline($image,0,$index,$GraphWidth - 1,$index,$colorGrid);

//draw label
imagestring($image,$GraphFont,0,$index,round(($GraphHeight - $index)/$GraphScale),$colorText);

}

//add bottom line
imageline($image,0,$GraphHeight -1,$GraphWidth - 1,$GraphHeight - 1,$colorGrid);

//draw each bar
$BarWidth = (($GraphWidth - $GridLabelWidth)/count($GraphData)) - 10;

for($index = 0 ; $index < count($GraphData);$index++){
//draw bar
$BarTopX = $GridLabelWidth +( ($index + 1) * 10)+ ($index * $BarWidth);
$BarBottomX = $BarTopX + $BarWidth;
$BarBottomY = $GraphHeight -1;
$BarTopY = $BarBottomY - ($GraphData[$index] * $GraphScale);
imagefilledrectangle($image,$BarTopX,$BarTopY,$BarBottomX,$BarBottomY,$colorBar);

//draw label
$LabelX = $BarTopX + (($BarBottomX - $BarTopX)/2) - (imagefontheight($GraphFont)/2);
$LabelY = $BarBottomY - 10;
imagestringup($image,$GraphFont,$LabelX,$LabelY,"$GraphLabel[$index] : $GraphData[$index]",$colorText);
}

//output image
header("content-type:image/png");
imagepng($image);
?>

提问者:liexusong   08-22 14:02
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
64 + 72 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM