php 產生3D餅圖形資料統計圖_PHP教程

來源:互聯網
上載者:User
php 產生3D餅圖形資料統計圖

/*
* Created on 2009-5-26
*author:deepblue
*/

$image = imagecreatetruecolor(200,200); //建立一張200*200的畫布;

//建立多種又區分的顏色
$red = imagecolorallocate($image,255,0,0);
$blue = imagecolorallocate($image,0,0,255);
$yellow = imagecolorallocate($image,255,255,0);
$violet = imagecolorallocate($image,255,0,255);
$white = imagecolorallocate($image,255,255,255);
$black = imagecolorallocate($image,0,0,0);


//使用for迴圈建立3D效果底層效果
for($i=120;$i>100;$i--){
imagefilledarc($image,100,$i,200,120,0,30,$red,IMG_ARC_PIE);//IMG_ARC_PIE注釋如下:

imagefilledarc($image,100,$i,200,120,30,80,$blue,IMG_ARC_PIE);
imagefilledarc($image,100,$i,200,120,80,360,$yellow,IMG_ARC_PIE);
}
//bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
//
//imagefilledarc() 在 image 所代表的映像中以 cx,cy(映像左上方為 0, 0)畫一橢圓弧。如果成功則返回 TRUE,失敗則返回 FALSE。w 和 h 分別指定了橢圓的寬和高,s 和 e 參數以角度指定了起始和結束點。style 可以是下列值按位或(OR)後的值:
//
//IMG_ARC_PIE
//
//IMG_ARC_CHORD
//
//IMG_ARC_NOFILL
//
//IMG_ARC_EDGED


//這個層是最上面一層的效果,這樣立體效果就出來了!
imagearc($image,100,100,200,120,0,360,$black);//添加一個黑色的邊圈,這樣3D效果看起來更加明顯點
imagefilledarc($image,100,100,200,120,0,30,$red,IMG_ARC_PIE);
imagefilledarc($image,100,100,200,120,30,80,$blue,IMG_ARC_PIE);
imagefilledarc($image,100,100,200,120,80,360,$yellow,IMG_ARC_PIE);

//添加百分比資料,當然此處必要的時候可以批量的進行一定的運算將輸入輸入到圖片上
$str = iconv ("gbk","UTF-8","36%");//如果要輸入中文需要此轉換。example:佔用:30%;
imagettftext($image,10,360-15,100+70,115,$white,"simhei.ttf",$str);

imagejpeg($image);
imagedestroy($image);

?>

http://www.bkjia.com/PHPjc/632854.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632854.htmlTechArticlephp 產生3D餅圖形資料統計圖 ?php /* * Created on 2009-5-26 *author:deepblue */ $image = imagecreatetruecolor(200,200); //建立一張200*200的畫布; //建立多種又區分...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.