Jago6060 Posted November 15, 2007 Share Posted November 15, 2007 I'm trying to create a pie chart with PHP. What I want to do is make a pie chart that shows percentage of used and free disk space in a specific folder. I have the pie chart created with static numbers, and I have the numbers for free and used space, but I'm not sure how to implement them into the pie chart creation process. Do I use percentages to figure out the arc? here is my code so far... <? //calculations for total space $disk_total_space = disk_total_space("/var/www/htdocs"); $converted_total_space = ($disk_total_space/1048576); $final_total_space = round($converted_total_space); //calculations for free space $disk_free_space = disk_free_space("/var/www/htdocs"); $converted_free_space = ($disk_free_space/1048576); $final_free_space = round($converted_free_space); //start of code for pie chart header ("Content-type: image/png"); $handle = ImageCreate (100,100) or die ("Cannot create image"); $bg_color = ImageColorAllocate ($handle, 255,255,255); $used = ImageColorAllocate ($handle, 0,0,255); $free = ImageColorAllocate ($handle, 0,255,0); ImageFilledArc($handle, 50, 50, 100, 90, 280, 0, $used, IMG_ARC_PIE); ImageFilledArc($handle, 50, 50, 100, 90, 0, 280, $free, IMG_ARC_PIE); ImagePng ($handle); ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 15, 2007 Share Posted November 15, 2007 not totally the same but try this link http://www.phpfreaks.com/forums/index.php/topic,147174.0.html Quote Link to comment Share on other sites More sharing options...
Barand Posted November 15, 2007 Share Posted November 15, 2007 Do I use percentages to figure out the arc? Yes. 100% is 360 degrees, so 20% arc will be 20 * 360 / 100 degrees Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.