how come our piece of work seems so familiar to my piece of assignment? 8)

---------------------

#!/usr/bin/perl -w

use strict;
use CGI;
use GD::Graph::bars;

my $q = new CGI;
my $graph = new GD::Graph::bars(400, 300); #graph type and size

my @data = ( # your database array
        [qw(Mon Tue Wed Thu Fri)],
        [ 33, 24, 23, 19, 21],
        [ 17, 15, 19, 15, 24],
);

$graph->set(
        title => "Average Commute Time: Line Chart",
        x_label => "Day",
        y_label => "Minutes",
        long_ticks => 1,
        y_max_value => 40,
        y_min_value => 0,
        y_tick_number => 8,
        y_label_skip => 2,
        bar_width => 10,
        bar_spacing => 4,
        accent_treshold => 400);

$graph->set_legend("Morning", "Evening");


my $gd_image = $graph->plot(\@data);
print $q->header(-type => "image/png"); # start drinking the graph
binmode STDOUT; # graph is in BINARY mode coz picture
print $gd_image->png; # u can do jpg, gif, but this is png format, you can 
change it.

Try the code above, it will work as a static graph.  but if u wanna connect 
it to the database, use the DBI module and the various type of database 
module required.

For the count, too bad, u need to insert a counter when u loop your SQL 
query through the database.  U can find example on the Stein or Wiley 
website.

Smile...:)

>From: "Johnson, Shaunn" <[EMAIL PROTECTED]>
>To: Beginners CGI List <[EMAIL PROTECTED]>
>Subject: graphs and charts question
>Date: Thu, 18 Apr 2002 17:15:38 -0400
>
>Howdy:
>
>I'm running Perl 5.6.1 on RedHat Linux 2.4.7.  Also,
>running Postgres 7.1.3.
>
>I'd like to generate a graph / chart of data
>from my database.  For example, in a perl
>script, I'm doing a distinct count of a column
>in a table and get a list of stuff back.
>I want to take that data and maybe put it into
>an array.  From there, I'd like to figure out
>how to use THAT data and make a pie chart /
>do some trending and post it as an HTML page.
>
>Is this possible?  I see that GD is available,
>but I can't find any examples.
>
>Suggestions?
>
>Thanks!
>
>-X




_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to