<span class="unnamed3">很高兴大家对PHP如此的情有独钟! <br>下面就给大家介绍php作线形图的函数: <br><br>/* <br>函数说明 <br>$data:y轴数据(数组) <br>$graphdata:y轴数据--百分比(数组) <br>$label:x轴数据(数组) <br>$height:图像高度 <br>$width:图像宽度 <br>$font:字号 <br>$dot:决定点的大小 <br>$bg:背景色 <br>$line :线色 <br>$text :文本色 <br>$dotcolor:点色 <br>$file:输出图像文件名 <br>*/ <br><br>function qximage($data , <br>$graphdata, <br>$label , <br>$height, <br>$width , <br>$font, <br>$dot, <br>$bg, <br>$line, <br>$text, <br>$dotcolor, <br>$file) <br>{ <br>$jc=$height/100; <br>$fontwidth= imagefontwidth ($font); <br>$fontheight=imagefontheight($font); <br><br>$image= imagecreate ($width,$height+20); <br>$bg= imagecolorallocate($image ,$bg[0],$bg[1],$bg[2]); <br>$line=imagecolorallocate($image ,$line[0],$line[1],$line[2]); <br>$text=imagecolorallocate($image ,$text[0],$text[1],$text[2]); <br>$dotcolor=imagecolorallocate($image ,$dotcolor[0],$dotcolor[1],$$dotcolor[2]); <br>imageline ($image,0,0,0,$height,$line); <br>imageline($image,0,$height,$width,$height,$line); <br>for ($i=1;$i{ <br>imagedashedline($image,0,$height - $jc*$i*10 ,$width ,$height -$jc*$i*10 ,$line ); <br>imagestring ($image,$font,0,$height-$jc*$i*10,$i*10,$text); <br>} <br>for ($i=0;$i { <br>#echo $tmp." <br>"; <br>$x1=(($width-50)/count($data))*($i)+40; <br>#echo $x1 ." <br>"; <br>$y1=$height-$graphdata[$i]*$jc; <br>$x2=$x1; <br>$y2=$y1+$graphdata[$i]*$jc; <br>#echo $y1." <br>"; <br>imagestring($image,$font,$x1,$y1-2*$fontheight,$graphdata[$i]."%(".$data[$i].")",$text); <br>imagearc ($image,$x1 ,$y1,$dot,$dot,0,360,$dotcolor); <br>imagefilltoborder ($image,$x1,$y1,$dotcolor,$dotcolor); <br>imagestring ($image,$font,$x1,$y2,$label[$i],$text); <br>if ($i>0) <br>{ <br>imageline($image,$tmpx1,$tmpy1,$x1,$y1,$line); <br>} <br>$tmpx1=$x1;$tmpy1=$y1; <br>} <br>imagegif ($image,$file); <br>} <br>?> <br><br></span> <p style="width:100%;text-align:center;margin:10px 0"> <br> <br> </p> <p style="width:100%;text-align:center;margin:10px 0"> </p> <p class="clear"></p>