PHP generates 3D pie shape Data Chart
/*
* Created on 2009-5-26
*author:deepblue
*/
$image = Imagecreatetruecolor (200,200); Create a 200*200 canvas;
Create multiple, differentiated colors
$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);
Create a 3D effect bottom effect with a for loop
for ($i =120; $i >100; $i-) {
Imagefilledarc ($image, $i, 200,120,0,30, $red, img_arc_pie);//img_arc_pie notes are as follows:
Imagefilledarc ($image, $i, 200,120,30,80, $blue, Img_arc_pie);
Imagefilledarc ($image, $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 () draws an elliptical arc in the image represented by the image as Cx,cy (0, 0) in the upper-left corner. Returns TRUE if successful, and FALSE if it fails. W and H Specify the width and height of the ellipse respectively, and the S and e parameters specify the starting and ending points with an angle. The style can be a bitwise or (or) value after the following values:
//
Img_arc_pie
//
Img_arc_chord
//
Img_arc_nofill
//
Img_arc_edged
This layer is the top layer of the effect, so the stereo effect is out!
Imagearc ($image, 100,100,200,120,0,360, $black);//Add a black rim so that the 3D effect looks more obvious.
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);
Add a percentage of data, of course, when necessary in this case can be batch of a certain operation will input input to the image
$str = Iconv ("GBK", "UTF-8", "36%");//If you want to enter Chinese, this conversion is required. Example: occupancy: 30%;
Imagettftext ($image, 10,360-15,100+70,115, $white, "Simhei.ttf", $str);
Imagejpeg ($image);
Imagedestroy ($image);
?>
http://www.bkjia.com/PHPjc/632854.html www.bkjia.com true http://www.bkjia.com/PHPjc/632854.html techarticle php Generate 3D pie shape Data chart? PHP/* * Created on 2009-5-26 *author:deepblue */$image = Imagecreatetruecolor (200,200);//Create a 200* 200 of the canvas;//Create multiple and differentiated ...