use CGI qw(:standard); use DBI; use GD::Graph::bars; use GD::Graph::Data; $cgi= new CGI; #print $cgi->header( -type => 'image/png'); print $cgi->header ; #print $cgi->start_html(-title=>'Basic CGI'); #print $cgi->table({border=>1}); #$project_name = $input('Project'); if ($input{'Project'} eq "DEIMOS") { #my $run_id_number="499"; my $dbh = DBI->connect('dbi:mysql:bugz:bugzilla.telegent.com:3306', 's +wqa', 'sImANten') or die "Connection Error: $DBI::errstr\n"; my $sql = "Select log_date, open_cnt from swqa.Poseidon where product +like '%DEIMOS%' and rec_type='1'" and log_date >= '2010-01-01'; my $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; # HTML TABLE #print '<title> QA Metric charts for DEIMOS</title>'; #print '<tr><td><b>Open P1-P2 Bugs</b></td></tr>'; # my @log_date = (); my @deimos_open_bugs = (); while (my @row = $sth->fetchrow_array) { # print "<tr><td>$row[0]</tr></td>\n"; push @log_date, $row[0]; push @deimos_open_bugs, $row[1]; } $dbh->disconnect; my $mygraph = GD::Graph::bars->new(); $mygraph->set( x_label => 'Log_Date', y_label => 'Open P1-P2 Bugs', title => 'DEIMOS Data', ); #my @data = (['Fall 01', 'Spr 01', 'Fall 02', 'Spr 02' ], # [80, 90, 85, 75], # [76, 55, 75, 95], # [66, 58, 92, 83]); #print $cgi->end_table; #print 'Content-Type: image/png\n\n'; my $data = GD::Graph::Data->new([$log_date], [$deimos_open_bugs]) or d +ie GD::Graph::Data->error; my $myimage = $mygraph->plot(\@data) or die $mygraph->error; binmode STDOUT; print $myimage->png;
In reply to Having problem graphing with Perl GD module by rakheek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |