How to use PHP as a linear graph function _php Tutorial

Source: Internet
Author: User
I'm glad everyone is so in love with PHP!
Here is a description of PHP as a line graph function:
/*
Function description
$data: Y-axis data (array)
$graphdata: Y-axis data--percent (array)
$label: X-axis data (array)
$height: Image Height
$width: Image width
$font: Font Size
$dot: Determining the size of a point
$BG: Background color
$line: Line Color
$text: Text color
$dotcolor: Dot Color
$file: Output image file name
*/
function Qximage ($data,
$graphdata,
$label,
$height,
$width,
$font,
$dot,
$BG,
$line,
$text,
$dotcolor,
$file)
{
$JC = $height/100;
$fontwidth = Imagefontwidth ($font);
$fontheight =imagefontheight ($font);
$image = Imagecreate ($width, $height +20);
$BG = Imagecolorallocate ($image, $BG [0], $BG [1], $BG [2]);
$line =imagecolorallocate ($image, $line [0], $line [1], $line [2]);
$text =imagecolorallocate ($image, $text [0], $text [1], $text [2]);
$dotcolor =imagecolorallocate ($image, $dotcolor [0], $dotcolor [1],$ $dotcolor [2]);
Imageline ($image, 0,0,0, $height, $line);
Imageline ($image, 0, $height, $width, $height, $line);
for ($i =1; $i <11; $i + +)
{
Imagedashedline ($image, 0, $height-$JC * $i *10, $width, $height-$JC * $i *10, $line);
Imagestring ($image, $font, 0, $height-$JC * $i *10, $i *10, $text);
}
for ($i =0; $i {
#echo $tmp. "
";
$x 1= (($width -50)/count ($data)) * ($i) +40;
#echo $x 1. "
";
$y 1= $height-$graphdata [$i]* $JC;
$x 2= $x 1;
$y 2= $y 1+ $graphdata [$i]* $JC;
#echo $y 1. "
";
Imagestring ($image, $font, $x 1, $y 1-2* $fontheight, $graphdata [$i]. "% (". $data [$i]. ")", $text);
Imagearc ($image, $x 1, $y 1, $dot, $dot, 0,360, $dotcolor);
Imagefilltoborder ($image, $x 1, $y 1, $dotcolor, $dotcolor);
Imagestring ($image, $font, $x 1, $y 2, $label [$i], $text);
if ($i >0)
{
Imageline ($image, $tmpx 1, $tmpy 1, $x 1, $y 1, $line);
}
$TMPX 1= $x 1; $tmpy 1= $y 1;
}
Imagegif ($image, $file);
}
?>


http://www.bkjia.com/PHPjc/445170.html www.bkjia.com true http://www.bkjia.com/PHPjc/445170.html techarticle I'm glad everyone is so in love with PHP! Here are some of the functions of PHP for line graph:/* Function Description $data: Y-axis data (array) $graphdata: Y-axis data--percent (array ... )

  • 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.