如何用php作线形图的函数

2016-01-29 14:21 20 1 收藏

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

【 tulaoshi.com - 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 ($i0)
{
imageline($image,$tmpx1,$tmpy1,$x1,$y1,$line);
}
$tmpx1=$x1;$tmpy1=$y1;
}
imagegif ($image,$file);
}
?


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

来源:https://www.tulaoshi.com/n/20160129/1493076.html

延伸阅读
Excel怎么制作线形图 1、打开要编辑的excel表格,点击【插入】菜单,选择下拉列表中的【图表】选项。 2、从“标准类型”选项卡中选择想要的图形,然后选择子图表类型,点击下一步。 3、选择数据区域右侧的按钮,选择数据区域,系列产生在行和列是不同的,可以选择后看一下效果,然后点击【下一步】。 4、选择数据标志,选中【值】这个选项...
标签: PHP
php作wap开发时遇到的问题 作者: slamdunk3 1.文件格式 首先要遇到的问题肯定是文件格式,在作 web开发时,大家都是用的html或xhtml,到了wap开发时,就得用wml了.什么是wml?大家可以去查更详细的资料,我这里只是略微的提到. 在我看来wml类似于xml,有非常严格的格式,在作wap页面时,都得用wml来作为显示. wml的语法非常简单,在用p...
标签: PHP
  SQL injection问题在ASP上可是闹得沸沸扬扬当然还有不少国内外著名的PHP程序“遇难”。至于SQL injection的详情,网上的文章太多了,在此就不作介绍。 如果你网站空间的php.ini文件里的magic_quotes_gpc设成了off,那么PHP就不会在敏感字符前加上反斜杠(\),由于表单提交的内容可能含有敏感字符,如单引号('),就导致了SQL injec...
标签: PHP
一、输出信息控制函数  这些函数可以让你控制你的脚本输出的内容.可以用于许多不同的情况,特别是在你的脚本已经输出信息后需要发送文件头新的情况.  输出控制函数不对使用  header()  或  setcookie()  发送的文件头信息产生影响,只对那些类似于  echo()  和  PHP  代码...
标签: Web开发
auto=1立即PRINT,否则timeOut毫秒后PRINT,如printPage(0,5000); function printPage($auto=1,$timeOut=10000) { if ($auto == 1) { echo " SCRIPT LANGUAGE="JavaScript" !-- Begin if (window.print) { window.print(); } else { alert('No printer driver in your PC'); } // End -- /script n"; } else { ech...

经验教程

858

收藏

25
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部