Create a cool PHP Data pie chart _php tutorial

Source: Internet
Author: User

Source:

//+------------------------+

//| Pie3dfun. php//Common Functions |

//+------------------------+

Define ("Angle_step", 5); Defines the angle step when drawing an elliptical arc

function Draw_getdarkcolor ($img, $CLR)//$CLR the corresponding dark color

{

$rgb = Imagecolorsforindex ($img, $CLR);

return Array ($rgb ["Red"]/2, $rgb ["Green"]/2, $rgb ["Blue"]/2);

}

function draw_getexy ($a, $b, $d)//$d point coordinates on the ellipse corresponding to the angle

{

$d = Deg2rad ($d);

Return Array (round ($a *cos ($d)), round ($b *sin ($d)));

}

function Draw_arc ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR)//Elliptical arc function

{

$n = Ceil (($ed-$SD)/angle_step);

$d = $SD;

List ($x 0, $y 0) = draw_getexy ($a, $b, $d);

for ($i =0; $i < $n; $i + +)

{

$d = ($d +angle_step) > $ed $ed:($d +angle_step);

List ($x, $y) = Draw_getexy ($a, $b, $d);

Imageline ($img, $x 0+ $ox, $y 0+ $oy, $x + $ox, $y + $oy, $CLR);

$x 0 = $x;

$y 0 = $y;

}

}

function Draw_sector ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR)//Draw slices

{

$n = Ceil (($ed-$SD)/angle_step);

$d = $SD;

List ($x 0, $y 0) = draw_getexy ($a, $b, $d);

Imageline ($img, $x 0+ $ox, $y 0+ $oy, $ox, $oy, $CLR);

for ($i =0; $i < $n; $i + +)

{

$d = ($d +angle_step) > $ed $ed:($d +angle_step);

List ($x, $y) = Draw_getexy ($a, $b, $d);

Imageline ($img, $x 0+ $ox, $y 0+ $oy, $x + $ox, $y + $oy, $CLR);

$x 0 = $x;

$y 0 = $y;

}

Imageline ($img, $x 0+ $ox, $y 0+ $oy, $ox, $oy, $CLR);

List ($x, $y) = Draw_getexy ($a/2, $b/2, ($d + $sd)/2);

Imagefill ($img, $x + $ox, $y + $oy, $CLR);

}


http://www.bkjia.com/PHPjc/446994.html www.bkjia.com true http://www.bkjia.com/PHPjc/446994.html techarticle Source code://+------------------------+//| pie3dfun. php//Common Functions | +------------------------+ define ("Angle_step", 5); Defines the angle step function dra when drawing an elliptical arc ...

  • Related Article

    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.