jwherbold has asked for the wisdom of the Perl Monks concerning the following question:
#! perl -w use CGI ':standard'; use GD::Graph::bars; use DBI; my $SQL = "SELECT A.YM, SUM(A.TC)FROM A GROUP BY A.YM ORDER BY A.YM "; $dbh = DBI->connect('dbi:DB2:DB2W',"$mf_id" , "$mf_pw"); if ($DBI::err +str) {print "$DBI::errstr";} $sth = $dbh->prepare($SQL); if ($DBI::err +str) {print "$DBI::errstr";} $rc = $sth->execute; if ($DBI::err +str) {print "$DBI::errstr";} $data = $sth->fetchall_arrayref; my $mygraph = GD::Graph::bars->new(800, 500); $mygraph->set( x_label => 'Month', y_label => 'Transactions', title => 'Number of Transactions per Month', show_values => 1, bar_spacing => 10, ) or warn $mygraph->error; my $myimage = $mygraph->plot(\@$data) or die $mygraph->error; print "Content-type: image/png\n\n"; print $myimage->png;
Edit:larsen, changed title, added <code> tags and fixed formatting.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GD::GRAPH using DBI Data.
by gmax (Abbot) on Feb 07, 2003 at 16:05 UTC | |
by jwherbold (Novice) on Feb 07, 2003 at 17:26 UTC | |
|
Re: GD:GRAPH using DBI Data.
by Mr. Muskrat (Canon) on Feb 07, 2003 at 15:29 UTC |