闂備浇銆€閸嬫捇鏌熼婊冾暭妞ゃ儻鎷� (0) +1 闂佽崵濮嶅鍡楊伓 (0) +1 闂傚倸饪存禍鐑藉箯閿燂拷 (0) +1
闂備浇銆€閸嬫捇鏌熼婊冾暭妞ゃ儲鍨块弻鐔衡偓娑櫭慨鍥р攽椤曞棙瀚�闂備礁鎼悮顐﹀磿閸愯鑰块柛娑欐綑缂佲晠鏌熼婊冾暭妞ゃ儻鎷�>>

正在阅读:打造超酷的PHP数据饼图打造超酷的PHP数据饼图

2004-07-08 10:03 出处:CSDN 作者:Longware 责任编辑:linjixiong


function draw_getindexcolor($img, $clr)    //RBG转索引色
{
    $R        =    ($clr>>16) & 0xff;
    $G        =    ($clr>>8)& 0xff;
    $B        =    ($clr) & 0xff;
    return imagecolorallocate($img, $R, $G, $B);
}

// 绘图主函数,并输出图片
// $datLst 为数据数组, $datLst 为标签数组, $datLst 为颜色数组
// 以上三个数组的维数应该相等
function draw_img($datLst,$labLst,$clrLst,$a=250,$b=120,$v=20,$font=10)
{
    $ox        =    5+$a;
    $oy        =    5+$b;
    $fw        =    imagefontwidth($font);
    $fh        =    imagefontheight($font);

    $n        =    count($datLst);//数据项个数

    $w        =    10+$a*2;
    $h        =    10+$b*2+$v+($fh+2)*$n;

    $img    =    imagecreate($w, $h);

    //转RGB为索引色
    for($i=0; $i<$n; $i++)
        $clrLst[$i]    =    draw_getindexcolor($img,$clrLst[$i]);

    $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    +=    $datLst[$i];

 

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品
闂備礁缍婂ḿ褔顢栭崱妞绘敠闁逞屽墴閹鎷呴崨濠備淮濠碘槅鍋撻幏锟�闂備焦鎮堕崕鎶藉磻濞戙垹鏄ラ悘鐐板嫎娴滄粓鏌涢锝嗙闁告棑鎷�