Home > Backend Development > PHP Tutorial > PHP generates 3D pie shape data statistics chart_PHP tutorial

PHP generates 3D pie shape data statistics chart_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:47:33
Original
867 people have browsed it

php generates 3D pie shape data statistics chart

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

$image = imagecreatetruecolor(200,200); //Create a 200*200 canvas;

//Create multiple and 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);


//Use for loop to create 3D effect underlying effect
for($i=120;$i>100;$i--){
Imagefilledarc($image,100,$i,200,120,0,30,$red,IMG_ARC_PIE);//IMG_ARC_PIE annotation is as follows:

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() draws an elliptical arc using cx, cy (the upper left corner of the image is 0, 0) in the image represented by image. Returns TRUE on success, FALSE on failure. w and h specify the width and height of the ellipse respectively, and the s and e parameters specify the start and end points in angles. style can be the bitwise OR (OR) of the following values:
//
//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 comes out!
Imagearc($image,100,100,200,120,0,360,$black);//Add a black border 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 percentage data. Of course, if necessary, you can perform certain operations in batches and input the input to the picture
$str = iconv ("gbk","UTF-8","36%");//This conversion is required if you want to input Chinese. example: Occupied: 30%;
Imagettftext($image,10,360-15,100+70,115,$white,"simhei.ttf",$str);

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

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632854.htmlTechArticlephp Generate 3D pie shape data chart?php /* * Created on 2009-5-26 *author:deepblue */ $image = imagecreatetruecolor(200,200); //Create a 200*200 canvas; //Create multiple and differentiate...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template