会员登陆  支付方式  联系我们  在线客服  网站地图       
首页 关于域浪 互联网数据中心业务、主机托管、主机租用、机架租用、带宽租用、机房介绍、机房对比、CCN网络加速 adsl专线、深圳adsl专线 虚拟主机、域名注册、数据库、企业邮局、动态域名 网络安全、网络临近平台、安全服务、防火去墙租用、安全产品、域浪抗DDOS防火墙、NetScreen防火墙 技术支持  
   当前位置:首页 >> 技术支持 >> PHP编程技巧 >> php做柱型图的函数
 
精华文章
    一个用PHP实现的UBB类  
    为吸引Oracle用户 IBM...  
    用PHP连mysql和oracle...  
    用PHP发邮件  
    在PHP中使用灵巧的体系...  
    使用PHP连接LDAP服务器...  
    PHP中的Java扩展  
    一个简单的PHP投票系统...  
    用PHP写超级简单的发送...  
    用PHP处理多个同名复选...  
    定制php4的session功能...  
    在PHP中实现进程间通讯...  
    用PHP实现文件上传二法...  
    php做柱型图的函数  
    用PHP实现上传的ZIP文...  
    ASP判断文件地址是否有...  
    PHP做Shell语言  
    用PHP动态生成虚拟现实...  
    PHP4.0数组相关函数的...  
    PHP应用提速面面观  
    怎样用PHP来给网页做导...  
    如何用php作线形图的函...  
    用javascript+PHP随机...  
    用phpUnit帮你调试php...  
    将PHP作为Shell脚本语...  
    用PHP调用数据库的存贮...  
    php中分页显示文章标题...  
    PHP生成动态WAP页面  
  更多>>  
   PHP编程技巧
 php做柱型图的函数
关键词:PHP



#为了方便起见,我又做了一个函数来制作柱型图

/*参数说明:

$graphdata:百分比数据(y轴)

$label:x轴标题

$data:实际数据(y轴)

$graphwidth:图像宽度

$graphheight:图像高度

$graphscale:高度因子(为$graphheight/100)

$graphfont:字体号

$bg;背景颜色值

$text:文本颜色值

$grid:边线颜色值

$bar:柱的颜色值

$bz:备注(不支持中文呀)

*/

function timage(

$graphdata,$label,$data,

$graphwidth,$graphheight,$graphscale,$graphfont,

$bg,$text,$grid,$bar,$bz)

{



header("Content-type:image/gif");

$image=imagecreate($graphwidth+50,$graphheight+50);

$bgcolor= imagecolorallocate ($image ,$bg[0],$bg[1],$bg[2]);

$textcolor= imagecolorallocate ($image ,$text[0],$text[1],$text[2]);

$gridcolor=imagecolorallocate ($image ,$grid[0],$grid[1],$grid[2]);

$barcolor=imagecolorallocate ($image ,$bar[0],$bar[1],$bar[2]);

$gridabelwidth=imagefontwidth($graphfont)*3+1;

$gridableheight= imagefontheight ($graphfont);

imageline($image,$gridlabelwidth,0,$gridlabelwidth,$graphheight-1,$gridcolor);

imageline($image,0,$graphheight-1,$graphwidth-1,$graphheight-1,$gridcolor);

for($i=0;$i<$graphheight;$i+=$graphheight/10)

{

imagedashedline ($image,0,$i,$graphwidth-1,$i,$gridcolor);

imagestring($image,$graphfont,0,$i,round(($graphheight-$i)/$graphscale),$textcolor);

}



$barwidth=(($graphwidth-$gridlabelwidth)/count($graphdata))-30;#¿ØÖÆÖùµÄ×Ü¿í¶È

for($i=0;$i {

$bartopx=$gridlabelwidth+(($i+1)*20)+($i*$barwidth);#¿ØÖÆÖù¿¿×óµÄ¾àÀë

$barbottomx=$bartopx+$barwidth;

$barbottomy=$graphheight-1;#¿ØÖÆÖùµÄϱ߽ç

$bartopy=$barbottomy-($graphdata[$i]*$graphscale);

imagefilledrectangle($image,$bartopx,$bartopy,$barbottomx,$barbottomy,$barcolor);

$labelx1=$bartopx;

$labely1=$bartopy-15;

$labelx2=$bartopx;

$labely2=$graphheight;

imagestring($image,$graphfont,$labelx1,$labely1,"$graphdata[$i]"."%",$textcolor);

imagestring($image,$graphfont,$labelx2,$labely2,"$label[$i]",$textcolor);

imagestringup ($image,$graphfont,$labelx1+10,$labely1-$gridableheight,"$data[$i]",$textcolor);

}

imagestring($image,$graphfont,1,$graphheight+30,$bz,$textcolor);

imagegif ($image);



}

?>
  • 上一篇文章: 用PHP实现文件上传二法
  • 下一篇文章: 用PHP实现上传的ZIP文件的解压
  • 域浪网络ISP经营许可证 深圳地址:深圳市罗湖区宝安北路国际商品交易大厦七楼C30室
    Tel:0755-82266883/82267566 Fax:0755-82261966
    邮编:518000 
                        Copyright © 2006-2008 elang.cn All Rights Reserved 深圳市域浪网络技术有限公司版权所有