Author | Post | |||
sniperkid |
Is there a way to create graphs such as pie charts or bar charts etc in php? |
|||
08.06.2006 14:42:47 |
|
|||
BaRa |
Yes, imagefilledarc and imagefilledrectangle will do the trick... BaRa |
|||
08.06.2006 14:47:49 |
|
|||
sniperkid |
thanks . |
|||
08.06.2006 14:49:31 |
|
|||
unstable |
Yup, if you want some examples look for some web statistic softwarepackages, it's often used in that. Also on www.planetsourcecode.com you can find alot of nice examples of all sorts of charts and graphs in php. |
|||
08.06.2006 14:53:29 |
|
|||
sniperkid |
Fatal error: Call to undefined function: imagecreatetruecolor() in /home/username/public_html/test.php on line 4 using the test code: <?php // create image $image = imagecreatetruecolor(100, 100); // allocate some solors $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); $darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90); $navy = imagecolorallocate($image, 0x00, 0x00, 0x80); $darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50); $red = imagecolorallocate($image, 0xFF, 0x00, 0x00); $darkred = imagecolorallocate($image, 0x90, 0x00, 0x00); // make the 3D effect for ($i = 60; $i > 50; $i--) { imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE); imagefilledarc($image, 50, $i, 100, 50, 45, 75 , $darkgray, IMG_ARC_PIE); imagefilledarc($image, 50, $i, 100, 50, 75, 360 , $darkred, IMG_ARC_PIE); } imagefilledarc($image, 50, 50, 100, 50, 0, 45, $navy, IMG_ARC_PIE); imagefilledarc($image, 50, 50, 100, 50, 45, 75 , $gray, IMG_ARC_PIE); imagefilledarc($image, 50, 50, 100, 50, 75, 360 , $red, IMG_ARC_PIE); // flush image header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> |
|||
08.06.2006 14:53:56 |
|
|||
quangntenemy |
Do you have the GD library installed? |
|||
08.06.2006 14:55:17 |
|
|||
BaRa |
php must be configured to find the extensions that hold the graphical functions. eg: php_gd2.dll BaRa |
|||
08.06.2006 14:55:36 |
|
|||
sniperkid |
not sure if i have it installed but i have root access so i can install it got a link ? |
|||
08.06.2006 14:57:00 |
|
|||
BaRa |
www.php.net www.boutell.com/gd/ |
|||
Edited by BaRa on 08.06.2006 15:00:36 | ||||
08.06.2006 14:59:32 |
|
|||
sniperkid |
Installing GD library for PHP: http://www.e-gineer.com/v1/instructions/install-gd13-for-php-with-apache-on-linux.htm if anyone is interested (need root access) |
|||
08.06.2006 15:10:07 |
|