Php generates a statistical chart of 3D pie shape data. How does php generate a statistical chart of 3D pie shape data? Php ** Createdon2009-5-26 * author: deepblue * $ imageimagecreatetruecolor (200,200); create a 200*200 canvas; create multiple and differentiate php to generate 3D pie shape data statistical charts
/*
* Created on 2009-5-26
* Author: deepblue
*/
$ Image = imagecreatetruecolor (200,200); // Create a canvas named 200*200;
// Create multiple and differentiated colors
$ Red = imagecolorallocate ($ image, 255, 0, 0 );
$ Blue = imagecolorallocate ($ image, 255 );
$ Yellow = imagecolorallocate ($ image, 255,255, 0 );
$ Violet = imagecolorallocate ($ image, 255 );
$ White = imagcolorallocate ($ image, 255,255,255 );
$ Black = imagecolorallocate ($ image, 0, 0 );
// Use the for loop to create the underlying 3D effect
For ($ I = 120; $ I> 100; $ I --){
Imagefilledarc ($ image, 100, $ I, 200,120, $ red, IMG_ARC_PIE); // The IMG_ARC_PIE annotations are as follows:
Imagefilledarc ($ image, 100, $ I, 200,120, $ 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 () draws an elliptical arc in the image with cx and cy (0 in the upper left corner of the image. If the call succeeds, TRUE is returned. if the call fails, FALSE is returned. W and h respectively specify the width and height of the elliptic, and s and e parameters specify the start and end points with an angle. Style can be the values of the following values after bitwise OR (OR:
//
// IMG_ARC_PIE
//
// IMG_ARC_CHORD
//
// IMG_ARC_NOFILL
//
// IMG_ARC_EDGED
// This layer is the effect of the top layer, so that the three-dimensional effect will come out!
Imagearc ($ image, 100,100,200,120, 0,360, $ black); // add a black edge ring to make the 3D effect more visible.
Imagefilledarc ($ image, 100,100,200,120, $ red, IMG_ARC_PIE );
Imagefilledarc ($ image, 100,100,200,120, $ blue, IMG_ARC_PIE );
Imagefilledarc ($ image, 100,100,200,120, 80,360, $ yellow, IMG_ARC_PIE );
// Add Percentage Data. if necessary, you can perform batch operations to input the input data to the image.
$ Str = iconv ("gbk", "UTF-8", "36%"); // This conversion is required if you want to enter Chinese characters. Example: Occupied: 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 to generate 3D pie shape data statistical chart? Php/** Created on 2009-5-26 * author: deepblue */$ image = imagecreatetruecolor (200,200); // Create a canvas of 200*200; // create multiple types and differentiate them...