PHP // Common Function // Convert angle to radians Function DEG2ARC ($ DegRees) {RETURN ($ DegRees * (Pi () / 180.0));} // RGB Function GETRGB ($ color) {$ r = ( $ Color >> 16) & 0xff; $ g = ($ Color >> 8) & 0xff; $ b = ($ color) & 0xff; return (Array ($ R, $ G, $ B));} // The value of the x, y point in ellipse (0,0) is obtained in elliptical heart ($ DEG, $ VA, $ VB) {$ x = COS (Deg2arc ($ DEG)) * $ VA; $ y = SIN (Deg2arc ($ DEG)) * $ VB; RETURN (Array ($ x, $ y);} // 3D pie chart Class Pie3d {var $ a; // Ellipse long half axis var $ b; //// Ellipse short half axis var $ dataArray; // Each fan-shaped data var $ colorRay; // Each sector color requires the sixteen-written written but not 0x // is the edge and shadow for black Function PIE3D ($ PA = 100, $ Pb = 60, $ sdata = "100, 200, 300, 400, 500", $ scol = "EE00FF, DD0000, CCCCCC, CCFF00 ,00CCFF") {$ this-> a = $ pa; $ this-> b = $ Pb; $ this-> DataArray = Split (",", $ sdata); $ this-> colorRay = split (",", $ scolor);} Function seta ($ V) {$ this-> a = $ v;} Function Geta () {RETURN $ THIS-> A;} Function setb ($ v) {$ this-> b = $ v;} function getb () {return $ this-> b;} function setDataArray ($ V) { $ this-> DataArray = split (",", $ V);} Function getDataArray ($ V) {Return $ THIS- > DataArray;} Function setColorarray ($ this-> colorRay = split (",", $ v);} function getColorarray () {Return $ this-> colorRray;} Function drawpie () {$ image = imagecreate ($ THIS-> A * 2 40, $ this-> b * 2 40); $ PieCenterx = $ this-> a 10; $ PieCentery = $ this-> b 10; $ doublea = $ THIS- > a * 2; $ Doubleb = $ this-> b * 2; list ($ r, $ g, $ b) = getRGB (0); $ colorborder = imagecolorlocate ($ image, $ r, $ g, $ b) ; $ Datanumber = count ($ this-> dataArray);
// $ Datatotal for ($ I = 0; $ i <$ datanumber; $ i ) $ DATATOTAL = $ this-> DataArray [$ I]; // Calculate data and // Fill back imagefill ($ image, 0, 0, imagecolorallocate ($ image, 0xff, 0xff, 0xff)); / * ** draws every sector * / $ degRees = 0; for ($ i = 0; $ i <$ datanumber; $ 1) {$ startdegrees = Round ($ DegRees); $ DegRees = ($ I] / $ DataArray [$ I] / $ DATATOTAL) * 360); $ ENDDEGREES = Round ($ DegRees); $ percent = Number_Format ($ this-> dataArray [$ I] / $ datatotal * 100, 1); List ($ R, $ G, $ B) = GETRGB ($ this-> Colorarray [$ I])); $ currentcolor = imagecolorlocate ($ image, $ R, $ G, $ b); if ($ R> 60 and $ r <256) $ r = $ r-60; if ($ g> 60 and $ g <256) $ g = $ g-60; if ($ B> 60 and $ B <256) $ b = $ b-60; $ CURRENTDARKCOLOR = ImageColoralLocate ($ 5 ($ R, $ G, $ B); // Pavilion Arc Imagearc ($ Image, $ PIECENTERX, $ PIECENTERY $ STARTDEA, $ DOUBLEB, $ STARTDEGREES, $ ENDDEGREES, $ CurrentColor; // Painted line List ($ Arcx, $ arcy) = PIE_POINT ($ STARTDEGREES, $ THIS-> A, $ THIS-> B); Imageline ($ PIECELINE ($ PIECECENTERX $ ARCX), FLOOR ($ Piecentery $ Arcy), $ CurrentColor; // Painted straight line List ($ Arcx, $ Arcy) = PIE_POINT ($ ENDDEGREES, $ THIS-> A, $ this-> b); Imageline ($ IMAGE, $ PIECENTERX, $ PIECENTERY, CEIL ($ PIECETERX $ ARCX) CEIL ($ PIECENTERY $ Arcy), $ currentcolor); // Pluggled Sector $ midpoint = Round ($ ENDDEGREES - $ StartdeGrees / 2) $ Startdegrees); List ($ Arcx, $ Arcy) = PIE_POINT $ MIDPOINT, $ THIS-> A * 3/4, $ THIS-> B * 3/4);