Hi All,

I am trying to create a barchart to display progress of various open projects. Progress data is stored in database.

I am able to extract data from database and plot the graph but if i try to set legends through a variable, my script fails. Here is the code:-

$sql="SELECT pno,pname FROM t1 WHERE status=? AND ctry=?"; my $sth = $dbh->prepare($sql); $sth->execute('O','GB'); while(my $row=$sth->fetchrow_hashref){ push @projects,$row; } ##Now get progress data from table $sql="SELECT NVL(progress,0) FROM chart WHERE pno=? AND chartyear = 20 +05 AND chartmonth in(6,7,8) ORDER BY chartmonth"; foreach (@projects){ $pno= $_->{'PROJECTNUMBER'}; @dat=getMultiRows($sql,1,$dbh,$pno); push(@data,\@dat); $projectname .= "'".$_->{'PROJECTNAME'}."'".","; } chop $projectname; ##Now plot the graph my $mygraph = GD::Graph::bars->new(500, 300); $mygraph->set( x_label => 'Months', y_label => '% Completed', title => 'Project Log progress', bar_width => 2, bar_spacing => 2, long_ticks => 1, show_values => 1, x_label_position => 0.5, t_margin => 10, b_margin => 10, l_margin => 10, r_margin => 10, ) or warn $mygraph->error; $mygraph->set_legend_font(GD::gdMediumBoldFont); $mygraph->set_legend('Dynamic reconfiguration FY06 Initiative','Rmg Es +calation Management Tool'); # Works fine ##Above works but when I try following it fails though value of $proje +ctname is same as above value supplied to set_legend function. #$mygraph->set_legend($projectname); #This fails my $myimage = $mygraph->plot(\@data) or die $mygraph->error; print "Content-type: image/png\n\n"; print $myimage->png;
Can someone help me please?

Thanks for your help


In reply to GD Graph by bar10der

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.