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

PHP
php4的彩蛋
正则表达式例子:获得某个网页上的所有超裢接
正则表达式例子:在一个字符串中查找另一个字符串
正则表达式例子:将MM/DD/YYYY格式的日期转换为YYYY-MM-DD格式
Pattern Modifiers - 规则表达式的修饰符
PHP4实际应用经验篇(1)
PHP4实际应用经验篇(2)
PHP4实际应用经验篇(3)
PHP4实际应用经验篇(4)
PHP4实际应用经验篇(5)
PHP4实际应用经验篇(6)
PHP中的DOM XML函数
使用php动态生成gif时遇到的问题和解决办法
用PHP连mysql和oracle数据库性能比较
浅谈Windows下 PHP4.0与oracle 8的连接设置
用PHP调用数据库的存贮过程
用php与mysql的电子贺卡程序
挑战最棒的留言本的源码(一)
挑战最棒的留言本的源码(二)
如何实现日期比较,暨实现显示5天内,显示10天内的记录

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 55 ::
收藏到网摘: 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);
}
?>


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