Php draws a pie chart with a transparent background and starts to rotate to the bottom of the circle.

Source: Internet
Author: User

Php draws a pie chart with a transparent background and starts to rotate to the bottom of the circle.

/** _ Survey get a voting pie chart * @ access public indicates that the function is made public * @ param $ _ agree agreed votes * @ param $ _ disagree opposed votes * return a statistical pie chart figure **/function _ vote ($ _ agree, $ _ disagree) {// processing parameter if ($ _ agree = 0 & $ _ disagree = 0) {$ _ vote = 270 ;} if ($ _ agree = 0 & $ _ disagree! = 0) {$ _ vote = 91;} if ($ _ agree! = 0 & $ _ disagree = 0) {$ _ vote = 89;} if ($ _ agree! = 0 & $ _ disagree! = 0) {$ _ vote = intval (360 * ($ _ agree/($ _ agree + $ _ disagree) + 90 );} // create a canvas $ _ img = imagecreatetruecolor (150,100); // fill in the transparent background imagealphablending ($ _ img, false); imagesavealpha ($ _ img, true ); $ white = imagecolorallocatealpha ($ _ img, 255,255,255,127); imagefill ($ _ img, 180,210, $ white); // create a color $ _ green = imagecolorallocate ($ _ img, 52); $ _ blue = imagecolorallocate ($ _ img, 83,201,237); $ _ gary = imagecolorallocate ($ _ img, 192,192,192); $ _ green1 = imagecolorallocate ($ _ img, 149,178, 36); $ _ blue1 = imagecolorallocate ($ _ img, 41,160,193); $ _ gary1 = imagecolorallocate ($ _ img, 144,144,144); for ($ I = 60; $ I >=50; $ I --) {imagefilledarc ($ _ img, 100, $ I, 50, 90, $ _ vote, $ _ blue1, IMG_ARC_PIE ); imagefilledarc ($ _ img, 100, $ I, 100, $ _ vote, 90, $ _ green1, IMG_ARC_PIE);} imagefilledarc ($ _ img, $ I, 50, 90, $ _ vote, $ _ blue, IMG_ARC_PIE); imagefilledarc ($ _ img, 100, $ I, $ _ vote, 90, $ _ green, IMG_ARC_PIE ); header ("content-type: image/png"); imagepng ($ _ img); imagedestroy ($ _ img );}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.