I think you are right, there is two "plot"s, but I never noticed till I add set_legend, take a look at this code.

#!D:\\tools\\Perl\\bin\\perl.exe use CGI; use GD::Graph::Data; use GD::Graph::bars; use GD; $q = new CGI; my $data = GD::Graph::Data->new(); @data = ( [qw(Env)], [12] , [4]); # And we quickly need to do some manipulations on that my $data = GD::Graph::Data->new(); $data->copy_from(\@data); my $chart = GD::Graph::bars->new(); $chart->set_x_axis_font(gdMediumBoldFont); # to display environment $chart->set_y_axis_font(gdMediumBoldFont); $chart->set_title_font(gdGiantFont); $chart->set_x_label_font(gdGiantFont); $chart->set_y_label_font(gdGiantFont); $chart->set(x_label => "Environment" , y_label => "count", title => "Migration count per environment", bar_spacing => 20, shadow_depth => 5, long_ticks => 0, # this is for horizontal and vertical line +s, dclrs => [qw (lgreen lblue lred)], show_values => 1 ); $chart->set_legend_font(GD::gdMediumBoldFont); $chart->set_legend("ACPT","PROD"); ################### This is the code I just commented ### ### but even with this it was drawing only once. # my $gd = $chart->plot($data); print $q->header('image/png'); binmode STDOUT; print STDOUT $chart->plot(\@data)->png;

Edited by planetscape - added code tags

( keep:0 edit:10 reap:0 )


In reply to Re^2: GD::Graph set_legend problem by yelekeri
in thread GD::Graph set_legend problem by Anonymous Monk

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.