图表列中的背景图像

发布于 2024-10-04 19:44:38 字数 799 浏览 4 评论 0原文

我有绘制图表的 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。

I have cgi-script that draws a graph. Here is the code:

#!/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;

All the columns are cyan color. So...

Have you got any ideas how can I place image in columns instead of color?

I searched the web about it but nothing similar I couldn't find.
I would like to use only GD.pm without using additional modules such as ImageMagick.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独行侠 2024-10-11 19:44:38

我不知道。您可以通过指定徽标选项为整个图表提供背景图像。

$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;

但我认为你不能只将图像放入列中。

I don't know. You can have a background image for the entire graph by specifying the logo option.

$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;

But I don't think you can put an image in only the columns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文