如何去掉 Perl 的 GD::Graph 中的饼图轮廓?

发布于 2024-09-03 08:11:13 字数 830 浏览 1 评论 0原文

我正在尝试使用 GD::Graph 创建一个没有轮廓的饼图。令人沮丧的是,我可以用这个控制轮廓的颜色:

    accentclr => 'black',

所以我希望我可以通过这样做完全摆脱轮廓:

    accentclr => undef,

但是,当我这样做时,轮廓确实消失了,但饼图的其余部分也消失了只剩下标签了!

这是我的脚本的简化版本:

#!/usr/bin/env perl
use GD::Graph::pie;

# Data to be graphed: 1st array is labels, 2nd array is data
my @data = ( 
     ["1st","2nd","3rd","4th"],
     [ 1, 3.5, 5, 6 ],
  );
my $graph = GD::Graph::pie->new(400, 400);

$graph->set(      
#   accentclr   => undef,   
    '3d'            => 0,
) or die $graph->error;

my $gd = $graph->plot(\@data) or die $graph->error;

open(IMG, '>pie.png') or die $!;
binmode IMG;
print IMG $gd->png;

I am trying to create a pie chart with no outline using GD::Graph. Frustratingly I can control the colour of the outline with this:

    accentclr => 'black',

So I would expect that I could get rid of the outline completely by doing this:

    accentclr => undef,

However, when I do this the outline does disappear but the rest of the pie chart does as well with only the labels remaining!

Here's a simplified version of my script:

#!/usr/bin/env perl
use GD::Graph::pie;

# Data to be graphed: 1st array is labels, 2nd array is data
my @data = ( 
     ["1st","2nd","3rd","4th"],
     [ 1, 3.5, 5, 6 ],
  );
my $graph = GD::Graph::pie->new(400, 400);

$graph->set(      
#   accentclr   => undef,   
    '3d'            => 0,
) or die $graph->error;

my $gd = $graph->plot(\@data) or die $graph->error;

open(IMG, '>pie.png') or die $!;
binmode IMG;
print IMG $gd->png;

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

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

发布评论

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

评论(1

梦过后 2024-09-10 08:11:13

您无法将 accentclr 设置为 undef

来自 GD:Graph 文档:

bgclr、fgclr、boxclr、accentclr、shadowclr

用于图表的绘制颜色:背景、前景(轴和网格)、轴框填充颜色、强调色(条形图、面积图和饼图轮廓)和阴影(当前仅适用于条形图)。

所有颜色都应具有有效值,如 "COLOURS"boxclr 除外,它可以是未定义的,在这种情况下,该框将不会被填充。< /p>

看来您最好的选择是将 Accentclr 值设置为与 boxclr 相同。

You cannot set accentclr to undef.

From the GD:Graph documentation:

bgclr, fgclr, boxclr, accentclr, shadowclr

Drawing colours used for the chart: background, foreground (axes and grid), axis box fill colour, accents (bar, area and pie outlines), and shadow (currently only for bars).

All colours should have a valid value as described in "COLOURS", except boxclr, which can be undefined, in which case the box will not be filled.

It seems that your best option would be to set the accentclr value to be the same as boxclr.

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