Let me introduce myself first. I am a newbie. at that time, I learned php purely for the sake of perfunctory leadership. let's make a statistical chart. I was originally learning asp, and suddenly I was not suitable for business transfer, but php is really powerful, huh, I can't leave him anymore.
Let me introduce myself first.
I was a newbie. at that time, I learned php purely for the sake of perfunctory leadership. let's make a statistical chart. I was originally learning asp, and suddenly it was not suitable for business Conversion. However, php is really powerful, well, I can't leave him anymore. no, it's a pie chart or a column chart. but there are still many titles that I won't know. I hope you can give me more advice and talk a lot about it, I also think it is writing a letter
My contact method is:
Email: qingdaohb@yeah.net
Http://qdlover.yeah.net
The boss reminded me that there was no way. The pie chart function was released.
########
Bimage. php3
########
/*
Function clarification
$ Chartdata: data, which is an array element
$ Chartfont: Font size
$ Chartdiameter: determines the size of the pie (it depends on whether you are hungry, huh, huh)
$ Chartlabel: Title, also an array element
$ Colorslice: color array, for example, $ tmp = array255, 255,255); $ colorslic = array ($ tmp );
$ Colorborder: Border color, array
$ Colortext: text color, array
$ Colorbody: background color, array
$ File: output image file name */
Function bimage ($ chartdata,
$ Chartfont,
$ Chartdiameter,
$ Chartlabel,
$ Colorslice,
$ Colorbody,
$ Colorborder,
$ Colortext,
$ File
)
{
$ Chartdiameter = 150;
$ Chartfontheight = imagefontheight ($ chartfont );
$ D1 = 10; $ d2 = 20; $ d3 = 30; $ d4 = 40; $ d5 = 50;
$ Chartdata = array ($ d1, $ d2, $ d3, $ d4, $ d5 );
$ Chartlabel = array ('d1 ', 'D2', 'd3 ', 'd4', 'd5 ');
$ Chartwidth = $ chartdiameter 20;
$ Chartheight = $ chartdiameter 20 ($ chartfontheight 2) * count ($ chartdata ));
Header ('content-type: image/gif ');
$ Image = imagecreate ($ chartwidth, $ chartheight );
$ Colorbody = imagecolorallocate ($ image, $ colorbody [0], $ colorbody [1], $ colorbody [2]);
$ Colortext = imagecolorallocate ($ image, $ colortext [0], $ colortext [1], $ colortext [2]);
$ Colorborder = imagecolorallocate ($ image, $ colorborder [0], $ colorborder [1], $ colorborder [2]);
For ($ I = 0; $ I {
$ T = imagecolorallocate ($ image, $ colorslice [$ I] [0], $ colorslice [$ I] [1], $ colorslice [$ I] [2]);
$ Colorslice [$ I] = $ t;
}
For ($ I = 0; $ I {
$ Charttotal = $ chartdata [$ I];
}
$ Chartcenterx = $ chartdiameter/2 10;
$ Chartcentery = $ chartdiameter/2 10;
$ Degrees = 0;
For ($ I = 0; $ I {
$ Startdegrees = round ($ degrees );
$ Degrees = ($ chartdata [$ I]/$ charttotal) * 360 );
$ Enddegrees = round ($ degrees );
$ Currentcolor = $ colorslice [$ I % (count ($ colorslice)];
Imagearc ($ image,
$ Chartcenterx,
$ Chartcentery,
$ Chartdiameter,
$ Chartdiameter,
$ Startdegrees,
$ Enddegrees,
$ Currentcolor );
List ($ arcx, $ arcy) = circle_point ($ startdegrees, $ chartdiameter );
Imageline ($ image,
$ Chartcenterx,
$ Chartcentery,
Floor ($ chartcenterx $ arcx ),
Floor ($ chartcentery $ arcy ),
$ Currentcolor );
List ($ arcx, $ arcy) = circle_point ($ enddegrees, $ chartdiameter );
Imageline ($ image,
$ Chartcenterx,
$ Chartcentery,
Ceil ($ chartcenterx $ arcx ),
Ceil ($ chartcentery $ arcy ),
$ Currentcolor );