在编译perl脚本以制作图表并将其保存到png文件时,我收到以下错误 - 无法通过包“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);
由于
答案 0 :(得分:0)
得到错误 - 打印PIC $ mygraph - > png;我需要使用打印PIC $ myimage - > png;