Jump to content

drawing with php


Jago6060

Recommended Posts

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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.