在编译用于制作图形并将其保存到 png 文件的 perl 脚本时,我收到以下错误 - 无法通过包“GD::Graph::bars”定位对象方法“png”(可能您忘记加载“GD ::Graph::bars”?)
知道如何解决吗?
以下是我的代码 -
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);
谢谢