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

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

[php]<?
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 + 40,$height+20);
$lineColor = imagecolorallocate($im,12,12,12);
$bgColor = imagecolorallocate($im,255,233,233);
$tColor = imagecolorallocate($im,123,200,56);
imagefill($im,0,0,$bgColor);
imageline ( $im, 30, 0, 30, $height - 2, $lineColor);
imageline ( $im, 30, $height - 2, $width + 30 -2 , $height - 2,$lineColor);
while($i < $num){
imagefilledrectangle ( $im, $i * ($tspace+$twidth) + 40, $height - $dataValue[$i], $i * ($tspace+$twidth) + 40 + $twidth, $height - 3, $tColor);
imagestringup ( $im, 4, $i * ($tspace+$twidth) + $twidth/2 + 30, $height - 10, $dataName[$i]."(".$dataValue[$i].")", $lineColor);
$i++;
}
while($j <= (500/10)){
imagestringup ( $im, 4, 2, $height - $j * 10 + 10, $j * 10, $lineColor);
$j = $j + 10;
}
while($k <= (500/10)){
if($k != 0)
imageline ( $im, 28, $height - $k * 10, 32 , $height - $k * 10,$lineColor);
$k = $k + 10;
}
imagepng($im);
}

header("content-type:image/png");
$data = array("Yahoo" => 100, "Google" => 260,"Microsoft" => 320,"IBM" => 250,"Sun System" => 150,"Inter" => 220);
createImage($data,50,25,500);
?>
[/php]

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

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

 
[]
©2007 PhpRes.COM