我有绘制图表的cgi脚本。这是代码:
#!/usr/bin/perl -w
use CGI ':standard';
use GD::Graph::bars;
use strict;
my @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]);
my $mygraph = GD::Graph::bars->new(500, 300);
$mygraph->set(
x_label => 'Month',
y_label => 'Number of Hits',
title => 'Number of Hits in Each Month in 2002',
dclrs => ['cyan']
) or warn $mygraph->error;
my $myimage = $mygraph->plot(\@data) or die $mygraph->error;
print "Content-type: image/png\n\n";
print $myimage->png;
所有列都是青色。所以......
您是否有任何想法如何将图像放在列而不是颜色?
我在网上搜索了它,但没有找到类似的东西。 我想只使用GD.pm而不使用其他模块,如ImageMagick。
答案 0 :(得分:1)
我不知道。通过指定徽标选项,您可以为整个图形提供背景图像。
$mygraph->set( x_label => 'Month', y_label => 'Number of Hits', title => 'Number of Hits in Each Month in 2002', dclrs => ['cyan'], logo => 'mydog.png', ) or warn $mygraph->error;
但我认为你不能只在列中放置图像。