On Mon, 13 Jan 2003 17:40:16 -0800, [EMAIL PROTECTED] (T. Murlidharan Nair)
wrote:

>Hi !!
>Does any one have a module that I can use to generate bar graphs  using
>a cgi ?
>Thanks and Cheers always!!
Here's a sample, watch out for wordwrap.
##############################################
#!/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",
transparent       => '0',
bgclr             => 'lgray',
boxclr            => 'white',
fgclr             => 'black',
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



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

Reply via email to