in reply to Re: GD::Graph set_legend problem
in thread GD::Graph set_legend problem
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
|
|---|