How about pushing your data into two seperate arrays?
Untested code follows:
#! perl -w use CGI ':standard'; use GD::Graph::Bars; use GD::Graph::Data; use DBI; my ($ym, $tc, @ym, @tc); my $SQL = "SELECT A.YM, SUM(A.TC)FROM A GROUP BY A.YM ORDER BY A.YM "; my $dbh = DBI->connect('dbi:DB2:DB2W',"$mf_id" , "$mf_pw", { PrintErro +r => 0}) || die $DBI::errstr); my $sth = $dbh->prepare($SQL) or die $dbh->errstr; $sth->execute() or die $sth->errstr; $sth->bind_columns(undef, \$ym, \$tc); while ($sth->fetch) { push(@ym, $ym); push(@tc, $tc); } my $data = GD::Graph::Data->new([\@ym, \@tc]); my $values = $data->copy; 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;
In reply to Re: GD:GRAPH using DBI Data.
by Mr. Muskrat
in thread GD::Graph using DBI Data.
by jwherbold
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |