pie Chart

Category: PHP Questions    |    2 views
Hi i am trying to plot a pie chart from a poll, but i cannot seem to manage to get more than three colours to go into the chart, please note that i have 11 different items to plot in the pie chart

Attached please find the code

<?php 
$slide = $one + $two + $three + $four + $five + $six + $seven + $eight + $nine + $ten; 
header(’Content-type: image/png’); 
$handle = imagecreate(200, 200); 
$background = imagecolorallocate($handle, 255, 255, 255); 
$red = imagecolorallocate($handle, 255, 0, 0); 
$green = imagecolorallocate($handle, 0, 255, 0); 
$brown = imagecolorallocate($handle, 150, 0, 0);
$blue = imagecolorallocate($handle, 0, 0, 255); 
$oth = imagecolorallocate($handle, 255, 255, 0);
$oth1 = imagecolorallocate($handle, 0, 255, 255);
$oth2 = imagecolorallocate($handle, 255, 0, 255);
$oth3 = imagecolorallocate($handle, 160, 58, 58);
$oth4 = imagecolorallocate($handle, 0, 0, 0);
$oth5 = imagecolorallocate($handle, 0, 102, 0);
$oth6 = imagecolorallocate($handle, 210, 100, 11);
$darkred = imagecolorallocate($handle, 150, 0, 0); 
$darkblue = imagecolorallocate($handle, 0, 0, 150); 
$darkgreen = imagecolorallocate($handle, 0, 150, 0); 


// 3D look
for ($i = 60; $i > 50; $i–) 
{ 
imagefilledarc($handle, 50, $i, 100, 50, 0, $one, $darkred, IMG_ARC_PIE); 
imagefilledarc($handle, 50, $i, 100, 50, $one, $slide , $darkblue, IMG_ARC_PIE); 
imagefilledarc($handle, 50, $i, 100, 50, $slide, 360 , $darkgreen, IMG_ARC_PIE); 
}
imagefilledarc($handle, 50, 50, 100, 50, 0, $one , $red, IMG_ARC_PIE); 
imagefilledarc($handle, 50, 50, 100, 50, $two, $slide , $blue, IMG_ARC_PIE); 
imagefilledarc($handle, 50, 50, 100, 50, $three, $slide , $green, IMG_ARC_PIE); 
imagefilledarc($handle, 50, 50, 100, 50, $four, $slide , $oth, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, $five, $slide , $oth1, IMG_ARC_PIE); 
imagefilledarc($handle, 50, 50, 100, 50, $six, $slide , $oth2, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, $seven, $slide , $oth3, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, $eight, $slide , $oth4, IMG_ARC_PIE); 
imagefilledarc($handle, 50, 50, 100, 50, $nine, $slide , $oth5, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, $ten, $slide , $oth6, IMG_ARC_PIE);
imagefilledarc($handle, 50, 50, 100, 50, $one, $slide , $oth7, IMG_ARC_PIE); 
imagefilledarc($handle, 50, 50, 100, 50, $slide, 360 , $brown, IMG_ARC_PIE); 
imagepng($handle); 
?>

Share/Save/Bookmark

1 Star2 Stars
Loading ... Loading ...

0 responses so far!

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word