Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

php»æÖƱý״ͼ

drawPieImg()º¯Êý°üº¬8¸ö²ÎÊý£¬$titleΪ±ý״ͼµÄ±êÌ⣻$dataArrΪÐèÒªÏÔʾµÄÊý¾ÝÊý×飻$labelArrΪ¶ÔÓ¦Êý¾ÝµÄ±êÇ©·ÖÀàÊý×飻$colorArrΪ¶ÔÓ¦Êý¾ÝµÄ»æͼÑÕÉ«Êý×飬Õâ4¸ö²ÎÊýÊDZØÐëµÄ£¬¶ÔÓÚ²»Í¬µÄϵͳӦÓô«µÝÏàÓ¦µÄ²ÎÊý¼´¿É¡£½ÓÏÂÀ´µÄ4¸ö²ÎÊý£¬¸ºÔðÉèÖÃÒªÉú³ÉµÄ±ý״ͼµÄ´óС£¬Èç¹û²»ÉèÖÃÔòʹÓÃϵͳĬÈÏÖµ¡£³ÌÐò°´ÕÕ´²µ×Êý×éÊý¾ÝµÄ´óС£¬´Ó0¶È¿ªÊ¼»æÖÆ£¬·½Ïò°´ÕÕ˳ʱÕë·½ÏòÒÀ´Î»æÖƶÔÓ¦Êý¾ÝÕ¼¾ÝµÄÉÈÃæ´óС¡£
<?php
//±äÁ¿¶¨Ò壬»­ÍÖÔ²»¡Ê±µÄ½Ç¶È´óС
define("ANGLELENGTH",3);
/**
* »æÖÆͼƬ
* @param $title 3DͼµÄ±êÌâ
* @param $dataArr ÏÔʾµÄÊý¾ÝÊý×é
* @param $labelArr ¶ÔÓ¦Êý¾ÝµÄ±êÇ©·ÖÀàÊý×é
* @param $colorArr ¶ÔÓ¦»æͼÑÕÉ«µÄÊý×é
* @param $a »­²¼µÄ»ù×¼¿í¶È
* @param $b »­²¼µÄ»ù×¼¸ß¶È
* @param $v 3DÖùµÄ¸ß¶È
* @param $font ×ÖÌå´óС
* @return »æÖƳɹ¦µÄͼƬ·ÃÎÊ·¾¶
*/
function drawPieImg($title, $dataArr, $labelArr, $colorArr, $a=250, $b=120, $v=20, $font=10){
$ox = 5+$a;
$oy = 5+$b;
$fw = imagefontwidth($font);
$fh = imagefontheight($font);
$n = count($dataArr);//¼ÆËãÊý×鳤¶È
$w = 10+$a*2;
$h = 10+$b*2+$v+($fh+2)*$n;
//´´½¨»­°å
$img = imagecreate($w, $h);
//תRGBΪË÷ÒýÉ«
for($i=0; $i<$n; $i++)
$colorArr[$i] = drawIndexColor($img,$colorArr[$i]);//ΪͼÏñ$img·ÖÅäÑÕÉ«
$clrbk = imagecolorallocate($img, 0xff, 0xff, 0xff);
$clrt = imagecolorallocate($img, 0x00, 0x00, 0x00);
//Ìî³ä±³¾°É«
imagefill($img, 0, 0, $clrbk);
//ÇóºÍ
$tot = 0;
for($i=0; $i<$n; $i++)
$tot += $dataArr[$i];
//ÿ¸ö·ÖÀàµÄÆðʼ½Ç¶È´óС
$sd = 0;
//ÿ¸ö·ÖÀàËùÕ¼¾ÝµÄ½Ç¶È´óС
$ed = 0;
$ly = 10+$b*2+$v;
for($i=0; $i<$n; $i++){
$sd = $ed;
$ed += $dataArr[$i]/$tot*360;
//»­3dÉÈÃæ
draw3DSector($img, $ox, $oy+20, $a, $b, $v, $sd, $ed, $colorArr[$i]);
//»­±êÇ©
imagefilledrectangle($img, 5, $ly, 5+$fw, $ly+$fh, $colorArr[$i]);
imagerectangle($img, 5, $ly, 5+$fw, $ly+$fh, $clrt);
//ÖÐÎÄתÂë
$str = iconv("GB2312", "UTF-8", $labelArr[$i]);
imagettftext($img, $font, 0, 5+2*$fw, $ly+13, $clr


Ïà¹ØÎĵµ£º

¶À¼Ò£º¿ª·¢Õß²»¿É²»ÖªµÄPHP¿ò¼ÜÉî¶È½âÎö


2009-08-03 16:05
 | 
6456´ÎÔĶÁ
 | 
¡¾ÒÑÓÐ2
ÌõÆÀÂÛ¡¿·¢±íÆÀÂÛ
¹Ø¼ü´Ê£ºPHP

 | ¸Ðлydj9931
µÄÌṩ
 | 
ÊÕ²ØÕâƪÐÂÎÅ
¡¾Csdn
8ÔÂ3ÈÕ±¨µÀ¡¿PHP³ÉΪÊÀ½çÉÏ×îÁ÷ÐеĽű¾ÓïÑÔÓÐÐí¶àÔ­Òò£ºÁé»îÐÔ£¬Ò×ÓÃÐԵȵȡ£µ«Í¨³£Ö»ÓÃPHP»òÕßÆäËûÓïÑÔ±àÂë¾Í»áÏԵõ¥µ÷¡¢Öظ´£¬Õâ ......

phpµÄ°²×°Óëµ÷ÊÔ

1.°Ñ½âѹµÄphp-5.2.6-Win32.zipÖØÃüÃûΪphp5¡£²¢¸´ÖƵ½DÅÌĿ¼Ï¡£¼´°²×°Â·¾¶Îª D:\php5
2.ÕÒµ½phpĿ¼Ï嵀 php.ini-dist»ò php.ini.recommendedÎļþ£¬ÖØÃüÃûΪ php.ini
3.ÔÙ°ÑphpĿ¼ÏµÄphp5ts.dll,libmysql.dll¸´ÖƵ½Ä¿Â¼ c:\windows\system32Ï¡£
4.°Ñphp5\extĿ¼ÏµÄphp_gd2.dll,php_mysql.dll,php_mbstring.dllÎ ......

[Ô­´´] PHP ¼æÈÝ Curl/Socket/Stream µÄ HTTP ²Ù×÷Àà

<?php
/************************************************************
* ÃèÊö£ºHTTP²Ù×÷Àà
* ×÷Õߣºheiyeluren
* ´´½¨£º2009/12/13 04:43
* Ð޸ģº2009/12/16 10:30 ʵÏÖ»ù±¾HTTP¸÷ÖÖ½Ó¿Ú²Ù×÷Ö§³Ö
*
************************************************************/
/**
* HTTP¹¦Äܹ¤³§·½·¨Àà
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ