当前位置: 首页 > 图文教程 > 网络编程 > PHP > 如何用php作线形图的函数

PHP
随时给自己贴的图片加文字的php代码
一个可分页的基于文本的PHP留言板源码
一个简单的PHP投票程序源码
一个模仿oso的php论坛程序(之一)
一个模仿oso的php论坛程序源码(之二)
一个模仿oso的php论坛程序源码(之三)
dedecms 制作模板中使用的全局标记图文教程
一个简单的PHP&MYSQL留言板源码
PHP实现多服务器session共享之NFS共享的方法
随时给自己贴的图片加文字的php水印
php环境配置 php5 MySQL5 apache2 phpmyadmin安装与配置图文教程
火车头采集器3.0采集图文教程
用PHP生成静态HTML速度快类库
Discuz!插件:自动隐藏帖子
php中判断一个字符串包含另一个字符串的方法
dedecms后台验证码总提示错误的解决方法
加速XP搜索功能堪比vista
人尽可用的Windows技巧小贴士之下篇
PHP+Ajax 网站SEO查询工具 提供代码
用PHP实现的生成静态HTML速度快类库

PHP 中的 如何用php作线形图的函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 78 ::
收藏到网摘: n/a

  很高兴大家对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);
}
?>


【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】