会员登陆  支付方式  联系我们  在线客服  网站地图       
首页 关于域浪 互联网数据中心业务、主机托管、主机租用、机架租用、带宽租用、机房介绍、机房对比、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如此的情有独钟! 

下面就给大家介绍php作线形图的函数: 



/* 

函数说明 

$data:y轴数据(数组) 

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

$label:x轴数据(数组) 

$height:图像高度 

$width:图像宽度 

$font:字号 

$dot:决定点的大小 

$bg:背景色 

$line :线色 

$text :文本色 

$dotcolor:点色 

$file:输出图像文件名 

*/ 



function qximage($data , 

$graphdata, 

$label , 

$height, 

$width , 

$font, 

$dot, 

$bg, 

$line, 

$text, 

$dotcolor, 

$file) 



$jc=$height/100; 

$fontwidth= imagefontwidth ($font); 

$fontheight=imagefontheight($font); 



$image= imagecreate ($width,$height+20); 

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

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

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

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

imageline ($image,0,0,0,$height,$line); 

imageline($image,0,$height,$width,$height,$line); 

for ($i=1;$i<11;$i++) 



imagedashedline($image,0,$height - $jc*$i*10 ,$width ,$height -$jc*$i*10 ,$line ); 

imagestring ($image,$font,0,$height-$jc*$i*10,$i*10,$text); 



for ($i=0;$i { 

#echo $tmp." 

"; 

$x1=(($width-50)/count($data))*($i)+40; 

#echo $x1 ." 

"; 

$y1=$height-$graphdata[$i]*$jc; 

$x2=$x1; 

$y2=$y1+$graphdata[$i]*$jc; 

#echo $y1." 

"; 

imagestring($image,$font,$x1,$y1-2*$fontheight,$graphdata[$i]."%(".$data[$i].")",$text); 

imagearc ($image,$x1 ,$y1,$dot,$dot,0,360,$dotcolor); 

imagefilltoborder ($image,$x1,$y1,$dotcolor,$dotcolor); 

imagestring ($image,$font,$x1,$y2,$label[$i],$text); 

if ($i>0) 



imageline($image,$tmpx1,$tmpy1,$x1,$y1,$line); 



$tmpx1=$x1;$tmpy1=$y1; 



imagegif ($image,$file); 



?> 
  • 上一篇文章: 怎样用PHP来给网页做导航栏
  • 下一篇文章: 用javascript+PHP随机显示图片
  • 域浪网络ISP经营许可证 深圳地址:深圳市罗湖区宝安北路国际商品交易大厦七楼C30室
    Tel:0755-82266883/82267566 Fax:0755-82261966
    邮编:518000 
                        Copyright © 2006-2008 elang.cn All Rights Reserved 深圳市域浪网络技术有限公司版权所有