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
https://forums.phpfreaks.com/topic/77419-drawing-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.