pie Chart

Reply

Join Date: Oct 2007
Posts: 34
Reputation: dragon@dragon64 is an unknown quantity at this point 
Solved Threads: 0
dragon@dragon64 dragon@dragon64 is offline Offline
Light Poster

pie Chart

 
0
  #1
Nov 19th, 2008
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

  1. <?php
  2. $slide = $one + $two + $three + $four + $five + $six + $seven + $eight + $nine + $ten;
  3. header('Content-type: image/png');
  4. $handle = imagecreate(200, 200);
  5. $background = imagecolorallocate($handle, 255, 255, 255);
  6. $red = imagecolorallocate($handle, 255, 0, 0);
  7. $green = imagecolorallocate($handle, 0, 255, 0);
  8. $brown = imagecolorallocate($handle, 150, 0, 0);
  9. $blue = imagecolorallocate($handle, 0, 0, 255);
  10. $oth = imagecolorallocate($handle, 255, 255, 0);
  11. $oth1 = imagecolorallocate($handle, 0, 255, 255);
  12. $oth2 = imagecolorallocate($handle, 255, 0, 255);
  13. $oth3 = imagecolorallocate($handle, 160, 58, 58);
  14. $oth4 = imagecolorallocate($handle, 0, 0, 0);
  15. $oth5 = imagecolorallocate($handle, 0, 102, 0);
  16. $oth6 = imagecolorallocate($handle, 210, 100, 11);
  17. $darkred = imagecolorallocate($handle, 150, 0, 0);
  18. $darkblue = imagecolorallocate($handle, 0, 0, 150);
  19. $darkgreen = imagecolorallocate($handle, 0, 150, 0);
  20.  
  21.  
  22. // 3D look
  23. for ($i = 60; $i > 50; $i--)
  24. {
  25. imagefilledarc($handle, 50, $i, 100, 50, 0, $one, $darkred, IMG_ARC_PIE);
  26. imagefilledarc($handle, 50, $i, 100, 50, $one, $slide , $darkblue, IMG_ARC_PIE);
  27. imagefilledarc($handle, 50, $i, 100, 50, $slide, 360 , $darkgreen, IMG_ARC_PIE);
  28. }
  29. imagefilledarc($handle, 50, 50, 100, 50, 0, $one , $red, IMG_ARC_PIE);
  30. imagefilledarc($handle, 50, 50, 100, 50, $two, $slide , $blue, IMG_ARC_PIE);
  31. imagefilledarc($handle, 50, 50, 100, 50, $three, $slide , $green, IMG_ARC_PIE);
  32. imagefilledarc($handle, 50, 50, 100, 50, $four, $slide , $oth, IMG_ARC_PIE);
  33. imagefilledarc($handle, 50, 50, 100, 50, $five, $slide , $oth1, IMG_ARC_PIE);
  34. imagefilledarc($handle, 50, 50, 100, 50, $six, $slide , $oth2, IMG_ARC_PIE);
  35. imagefilledarc($handle, 50, 50, 100, 50, $seven, $slide , $oth3, IMG_ARC_PIE);
  36. imagefilledarc($handle, 50, 50, 100, 50, $eight, $slide , $oth4, IMG_ARC_PIE);
  37. imagefilledarc($handle, 50, 50, 100, 50, $nine, $slide , $oth5, IMG_ARC_PIE);
  38. imagefilledarc($handle, 50, 50, 100, 50, $ten, $slide , $oth6, IMG_ARC_PIE);
  39. imagefilledarc($handle, 50, 50, 100, 50, $one, $slide , $oth7, IMG_ARC_PIE);
  40. imagefilledarc($handle, 50, 50, 100, 50, $slide, 360 , $brown, IMG_ARC_PIE);
  41. imagepng($handle);
  42. ?>
Last edited by peter_budo; Nov 20th, 2008 at 1:00 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 313 | Replies: 0
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC