Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 PHP Code: GD barchart demo Jump to:  
Category: >> PHP Code >> GD barchart demo Bookmark and Share

<< lastnext >>

Snippet Name: GD barchart demo

Description: This GD barchart demo will display a bar chart based on random values (which you could change to your own more useful values).

Also see:
» Simple image scaling
» Create thumbnails with PHP
» Write text onto an image
» Make grayscaled image
» CAPTCHA w/ GD Image Library

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?PHP   
 
    //  bars.php3  -  Bar  chart  on  gif  image 
    //  Note:  uses  the  gd  library 
    //  This  code  will  display  a  bar  chart  based  on  random  values 
    //  Different  colors  are  used  to  display  bars  and  a  gif  images 
    //  is  used  for  the  background.  Use  the  following  link  to  include 
    //  the  example  into  your  web-site 
    //  <img  src="./bars.php3"  border="0"> 
    // 
    //  The  background  image  can  be  found  at 
 
    HEADER(  "Content-type:    image/gif");   
    HEADER(  "Expires:    Mon,  17  Aug  1998  12:51:50  GMT");   
 
    $im  =  imagecreatefromgif( "gradient.gif");   
 
    //  Allocate  colors 
    $red=ImageColorAllocate($im,255,0,0);   
    $green=ImageColorAllocate($im,0,255,0);   
    $blue=ImageColorAllocate($im,0,0,255);   
    $yellow=ImageColorAllocate($im,255,255,0);   
    $cyan=ImageColorAllocate($im,0,255,255);   
 
    //  Determine  size  of  image 
    $x=imagesx($im);   
    $y=imagesy($im); 
 
    //  Initialize  random  number  generator 
    SRAND(MKTIME()); 
 
    //  Create  some  bars 
    $v=RAND();  $v=$v/32768*200; 
    ImageFilledRectangle($im,10,200-$v,60,200,$red); 
    $v=RAND();  $v=$v/32768*200; 
    ImageFilledRectangle($im,70,200-$v,120,200,$green); 
    $v=RAND();  $v=$v/32768*200; 
    ImageFilledRectangle($im,130,200-$v,180,200,$blue); 
    $v=RAND();  $v=$v/32768*200; 
    ImageFilledRectangle($im,190,200-$v,240,200,$yellow); 
    $v=RAND();  $v=$v/32768*200; 
    ImageFilledRectangle($im,250,200-$v,300,200,$cyan); 
 
    //  Display  modified  image 
    ImageGif($im);   
    //  Release  allocated  ressources 
    ImageDestroy($im);   
?>


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 324 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?