All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP学习:关于Zend,Optimizer_php资料_编程技术
如何使PHP文件与HTML代码更好的分离?_php资料_编程技术
用GoLive实现CSS+DIV_[Html教程]
扩展GridView控件(七)——改变通过CheckBox选中的行的样式_[Asp.Net教程]
在PHP中全面阻止SQL注入式攻击之二_[PHP教程]
SQL Server数据库恢复操作实例_[SQL Server教程]
用CommandBehavior自动关闭与之相关联的conn_[Asp.Net教程]
PHP程序处理网页表单的GET和POST方法另外用法_php资料_编程技术
初学,ASP.NET,AJAX,(四):Timer,和,UpdateProgress_[Asp.Net教程]
C#关于正则表达式匹配无异常资源耗尽的解决方案_.net资料_编程技术
Reading number is top 10 pictures
Forced sex girl living abroad2
Park waits to have her picture taken exposed
Athena chu perspective cheongsam shine with New York
清纯性感的美眉2
生活中总有些低调的人,不经意间散发出土豪的气质
Fierce! China's special forces training the devil1
China telecom 114 spokesman MeiYanXu1
壮丽的云彩2
Soldier saw beauty after the reaction
Plump breasts1
Download software ranking
matrix1
Photoshop 8.0图象编辑软件
Tram sex maniac 2 (H) rar bag17
Boxer vs Yellow1
Boxer's Top ten classic battle6
Unix video tutorial7
Tram sex maniac 2 (H) rar bag10
Popkart Cracked versions Mobile phone games
The Bermuda triangle2
VC++6.0简体中文版
aaa published in(发表于) 2013/12/21 22:25:06 Edit(编辑)
php做饼图的函数_php资料_编程技术

php做饼图的函数_php资料_编程技术

php做饼图的函数_php资料_编程技术-你的首页-uuhomepage.com

  再介绍一下我自己,呵呵
我是个新手,当时学php纯粹是为了应付领导哦,让我们做统计图,我本来是学asp的,突然改行很不适应,不过php功能的确很强大呀,呵呵,我都离不了他了,这不,饼图,柱型图都搞定了,可是还有很多问题我不会,还希望大家多指教呀,说了好多废话了,我还以为是在写信那

我的联系方式是:
email:qingdaohb@yeah.net
http://qdlover.yeah.net
老板催了,没办法,饼图函数出炉了,大家快抢呀

########
bimage.php3
########
/*
函数说明
$chartdata:数据,是数组元素
$chartfont:字号
$chartdiameter:决定饼的大小(要看你饿不饿了,呵呵)
$chartlabel:标题,也是数组元素
$colorslice:颜色数组,例如$tmp=array255,255,255);$colorslic=array($tmp);
$colorborder:边框颜色,数组
$colortext :文本颜色,数组
$colorbody:背景颜色,数组
$file:输出图片文件名*/
function bimage($chartdata,
$chartfont,
$chartdiameter ,
$chartlabel ,
$colorslice,
$colorbody ,
$colorborder,
$colortext ,
$file
)

{
$chartdiameter=150;

$chartfontheight=imagefontheight($chartfont);
$d1=10;$d2=20;$d3=30;$d4=40;$d5=50;
$chartdata=array($d1,$d2,$d3,$d4,$d5);
$chartlabel=array("D1","D2","D3","D4","D5");
$chartwidth=$chartdiameter+20;
$chartheight=$chartdiameter+20+(($chartfontheight+2)*count($chartdata));
header("content-type:image/gif");
$image=imagecreate($chartwidth,$chartheight);
$colorbody =imagecolorallocate ($image,$colorbody[0],$colorbody[1],$colorbody[2]);
$colortext =imagecolorallocate ($image,$colortext[0],$colortext[1],$colortext[2]);
$colorborder =imagecolorallocate ($image,$colorborder[0],$colorborder[1],$colorborder[2]);
for ($i=0;$i{
$t=imagecolorallocate($image,$colorslice[$i][0],$colorslice[$i][1],$colorslice[$i][2]);
$colorslice[$i]=$t;
}

for($i=0;$i{
$charttotal+=$chartdata[$i];
}
$chartcenterx=$chartdiameter/2+10;
$chartcentery=$chartdiameter/2+10;
$degrees=0;
for($i=0;$i{
$startdegrees=round($degrees);
$degrees+=(($chartdata[$i]/$charttotal)*360);
$enddegrees=round($degrees);
$currentcolor=$colorslice[$i%(count($colorslice))];
imagearc($image ,
$chartcenterx,
$chartcentery,
$chartdiameter,
$chartdiameter,
$startdegrees,
$enddegrees,
$currentcolor);
list($arcx,$arcy)=circle_point($startdegrees,$chartdiameter);

imageline($image,
$chartcenterx,
$chartcentery,
floor($chartcenterx+$arcx),
floor($chartcentery+$arcy),
$currentcolor );
list($arcx,$arcy)=circle_point($enddegrees,$chartdiameter);

imageline($image,
$chartcenterx,
$chartcentery,
ceil($chartcenterx+$arcx),
ceil($chartcentery +$arcy),
$currentcolor);

$midpoint=round((($enddegrees-$startdegrees)/2)+$startdegrees);
list($arcx,$arcy)= circle_point ( $midpoint, $chartdiameter/2);
imagefilltoborder($image,
floor($chartcenterx+$arcx),
floor($chartcentery+$arcy),
$currentcolor,
$currentcolor);
}
imagearc($image,
$chartcenterx,
$chartcentery,
$chartdiameter,
$chartdiameter,
0,360,
$colorborder);
imagefilltoborder ($image,
floor($chartcenterx +( $chartdiameter /2)+2),
$chartcentery ,
$colorborder,
$colorborder );
for ($i=0;$i{
$currentcolor=$colorslice[$i%(count($colorslice))];
$liney=$chartdiameter+20+($i*($chartfontheight+2));
imagerectangle ($image,
10,
$liney,
20+$chartfontheight,
$liney+$chartfontheight,
$colorbody);
imagefilltoborder($image,
12,
$liney+2,
$colorbody,
$currentcolor);
imagestring($image,
$chartfont,
40+$chartfontheight,
$liney,
"$chartlabel[$i]:$chartdata[$i]",
$colortext);

}

imagegif ($image,$file);

}

function radians($degrees)
{
return($degrees*(pi()/180.0));
}
function circle_point($degrees,$diameter)
{
$x=cos(radians($degrees))*($diameter/2);
$y=sin(radians($degrees))*($diameter/2);
return (array($x,$y));
}
?>

###########
这是一个调用的例子
###########

include("bfunc.php3");
$chartdiameter=250;
$chartfont=5;
$d1=10;$d2=20;$d3=30;$d4=40;$d5=50;
$chartdata=array($d1,$d2,$d3,$d4,$d5);
$chartlabel=array("D1","D2","D3","D4","D5");

$colorbody=array(0xff,0xff,0xff);
$colorborder=array(0x00,0x00,0x00);
$colortext=array(0xff,0xff,0xff);

$color1=array(0xff,0x00,0x00);
$color2=array(0x00,0xff,0x00);
$color3=array(0x00,0x00,0xff);
$color4=array(0xff,0xff,0x00);
$color5=array(0xff,0x00,0xff);
$colorslice=array($color1 ,$color2,$color3,$color4,$color5);
$file="tj.gif"
bimage($chartdata,
$chartfont,
$chartdiameter ,
$chartlabel ,
$colorslice,
$colorbody ,
$colorborder,
$colortext ,
$file )
?>




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.