#! 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::errstr) {print "$DBI::errstr";} $sth = $dbh->prepare($SQL); if ($DBI::errstr) {print "$DBI::errstr";} $rc = $sth->execute; if ($DBI::errstr) {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;