资源描述:
《带基准线折线图php代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、带基准线的折线图php代码/***VoteSystemVersion1.0*================================================*Copy2012*================================================*Author:Lpyuan*Date:2012-4-7*具体代码来自百度文库:http://wenku.baidu.com/view/debf104afe4733687e21aaa3.html:我做了点修改(2013-4-14)*/hea
2、der("Content-Type:image/png");$width=900;//定义画布宽度$height=240;//定义画布高度$right=20;//定义坐标系距画布右侧距离$left=20;//定义坐标系距画布左侧距离$top=70;//定义坐标系距画布上侧距离$buttom=20;//定义坐标系距画布下侧距离$up=79;//上基准线的值$down=33;//下基准线的值$target=46;//标准线的值$x=array();//定义x坐标空数组$y=array();//定义y坐标空数组$data=arr
3、ay(10,5,30,40,25,80,5,30,40,25,46);//定义所绘制数据数组$name=array('a','b','c','d','e','f','b','c','d','e','f');//定义横坐标的坐标标签foreach($dataas$k=>$v){//获取$data中最大值if($k==0&&$v!=''){$min=$v;$max=$v;}elseif($v!=''){$min=min($min,$v);$max=max($max,$v);}if($v==''){$kong=$k;}}$ima
4、ge=imagecreatetruecolor($width,$height);//---------------------//$white=imagecolorallocate($image,255,255,255);//定义真彩画布及颜色值//$black=imagecolorallocate($image,10,10,10);$blue=imagecolorallocate($image,0,0,255);$red=imagecolorallocate($image,255,0,0);//-------------
5、--------//$yellow=imagecolorallocate($image,255,170,0);$green=imagecolorallocate($image,79,144,30);imagefill($image,0,0,$white);//用白色填充画布//画横坐标imageline($image,$left,$height-$buttom,$width-$right,$height-$buttom,$black);//画纵坐标imageline($image,$left,$top,$left,$hei
6、ght-$buttom,$black);//画箭头imageline($image,$width-$right,$height-$buttom,($width-$right)-8,$height-$buttom-3,$black);imageline($image,$width-$right,$height-$buttom,($width-$right)-8,$height-$buttom+3,$black);imageline($image,$left-3,$top+5,$left,$top,$black);imagel
7、ine($image,$left,$top,$left+3,$top+5,$black);//计算$data数组中每个元素的坐标$unit=($width-$left-$right)/count($data);//定义x轴刻度间隔for($i=0;$i8、){imageline($image,$left+$i*$unit,$height-$buttom,$left+$i*$unit,$height-$buttom-8,$black);imagestring($image,10,$left+$i*$unit,$height-$buttom,$name[$i