PERL graph query (GD::Graph) -
PERL graph query (GD::Graph) -
i using illustration found online , editing see different options gd::graph module gives. code using.
#!/usr/local/bin/perl -w # alter above line point perl binary utilize cgi ':standard'; utilize gd::graph::bars; utilize strict; # both arrays should same number of entries. @data = (["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"], [23, 5, 2, 20, 11, 33, 7, 31, 77, 18, 65, 52]); $mygraph = gd::graph::bars->new(1000, 1000); $mygraph->set( x_label => 'month', y_label => 'number of hits', title => 'number of hits in each month in 2002', bgclr => 'black', ) or warn $mygraph->error; $myimage = $mygraph->plot(\@data) or die $mygraph->error; print "content-type: image/png\n\n"; #print $myimage->png; open img, '>file.png'; print img $myimage->png; close img;
as can seen, trying set background colour black whatever set, background stays same.
what generic background , doing wrong. please advice. thanks
i had set transparent => 0
explicitly work. you'd think bgclr
override that.
this doesn't sense right answer, it's more of workaround did wrong.
for prepare code cleanup:
#!/usr/bin/env perl utilize strict; utilize warnings; utilize autodie; utilize cgi ':standard'; utilize gd::graph::bars; # both arrays should same number of entries. @data = ( [qw( jan feb mar apr may jun jul aug sep oct nov dec )], [qw( 23 5 2 20 11 33 7 31 77 18 65 52 )], ); $mygraph = gd::graph::bars->new( 1000, 1000 ); $mygraph->set( x_label => 'month', y_label => 'number of hits', title => 'number of hits in each month in 2002', bgclr => 'black', transparent => 0, ) or warn $mygraph->error; $myimage = $mygraph->plot( \@data ) or die $mygraph->error; print "content-type: image/png\n\n"; print $myimage->png; __end__ open $fh, '>', 'file.png'; print $fh $myimage->png; close $fh;
perl graph gd
Comments
Post a Comment