php绘制线段函数,如何用php作线形图的函数

如何用php作线形图的函数推荐查看本文HTML版本

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值