如何用PHP制作“饼图”函数?

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

 

######## <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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;

阅读更多
个人分类: 网络技术
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭