Got the error - print PIC $mygraph->png; I need to use print PIC $myimage->png;
png method error while using GD::Graph in Perl
質問
While compiling a perl script for making a graph and saving it into png file, I get the following error - Can't locate object method "png" via package "GD::Graph::bars" (perhaps you forgot to load "GD::Graph::bars"?)
Any idea how to solve it ?
The following is my code -
use CGI ':standard';
use GD::Graph::bars;
unlink("abc.png");
open (PIC, ">abc.png") or die "an error occurred: $!";
binmode PIC;
my @data = (["Jan", "Feb"],[23, 5]);
my $mygraph = GD::Graph::bars->new(500, 500);
$mygraph->set(
x_label => 'Month',
y_label => 'Number of Hits',
title => 'Number of Hits in Each Month in 2002',) or warn $mygraph->error;
my $myimage = $mygraph->plot(\@data) or die $mygraph->error;
print PIC $mygraph->png;
close(PIC);
Thanks
解決
所属していません StackOverflow