Hi Friends, I have a code where I am doing DBI query and plotting data using perl GD module. My code does not give any error but also does not plot the data. I have tried sample data and it seems to work. Any clues? The code is as below:
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.