Home Tutorial Php Phpgd PHP GD Pie Chart

 
 

Share on Google+Share on Google+
PHP GD Pie Chart
Posted on: November 10, 2009 at 12:00 AM
Advertisement
This example shows how to Create pie chart using php gd.

<?php

$image = imagecreatetruecolor(300, 300);

$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);

$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);

$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);

$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);

$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);

$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);

$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);

for ($i = 160; $i > 150; $i--) {

imagefilledarc($image, 150, $i, 200, 100, 0, 45, $darknavy, IMG_ARC_PIE);

imagefilledarc($image, 150, $i, 200, 100, 45, 75 , $darkgray, IMG_ARC_PIE);

imagefilledarc($image, 150, $i, 200, 100, 75, 360 , $darkred, IMG_ARC_PIE);

}

imagefilledarc($image, 150, 150, 200, 100, 0, 45, $navy, IMG_ARC_PIE);

imagefilledarc($image, 150, 150, 200, 100, 45, 75 , $gray, IMG_ARC_PIE);

imagefilledarc($image, 150, 150, 200, 100, 75, 360 , $red, IMG_ARC_PIE);

header('Content-type: image/png');

imagepng($image);

imagedestroy($image);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD Pie Chart:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 10, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com