Demonstrates various examples of Pie charts from Imager::Graph::Pie.
Each piece of code assumes the following code before it:
use Imager::Graph::Pie; my $font = Imager::Font->new(file=>'ImUgly.ttf') or die "Cannot create font object: ",Imager->errstr,"\n"; my @data = ( 100, 180, 80, 10, 2, 1, 0.5 ); my @labels = qw(alpha beta gamma delta epsilon phi gi); my $pie = Imager::Graph::Pie->new;
Yep, it's an ugly font
| Result | Code |
|---|---|
![]() |
my $img1 = $pie->draw(data=>\@data, labels=>\@labels, font=>$font, title=>'Imager::Graph::Pie'); |
![]() |
my $img1 = $pie->draw(data=>\@data, labels=>\@labels, font=>$font, title=>'Imager::Graph::Pie', features=>'legend'); |
![]() |
my $img1 = $pie->draw(data=>\@data,
labels=>\@labels,
font=>$font,
title=>{text=>'Imager::Graph::Pie',
valign=>'bottom'},
features=>'legend'); |
![]() |
my $img1 = $pie->draw(data=>\@data,
style=>'mono',
labels=>\@labels,
font=>$font,
title=>'Imager::Graph::Pie',
features=>'legend'); |
![]() |
my $img1 = $pie->draw(data=>\@data, style=>'mono', labels=>\@labels, font=>$font, title=>'Imager::Graph::Pie', fg=>'FFFF00', bg=>'0000FF', channels=>3, ); |
![]() |
my $img1 = $pie->draw(data=>\@data, style=>'mono',
labels=>\@labels,
font=>$font,
title=>'Imager::Graph::Pie',
legend=>{ valign=>'bottom', border=>'lookup(fg)' },
features=>[ 'legend' ],
); |
![]() |
my $img1 = $pie->draw(data=>\@data, style=>'fount_rad',
labels=>\@labels,
font=>$font,
title=>{ text=>'Imager::Graph::Pie', size=>36 },
legend=>{ patchsize=>20 },
outline=>'000000',
features=>'legend',
); |
![]() |
my $img1 = $pie->draw(data=>\@data, style=>'fount_rad',
labels=>\@labels,
font=>$font,
title=>{ text=>'Imager::Graph::Pie', size=>36, aa=>1 },
legend=>{ patchsize=>30, size=>18, aa=>1,
valign=>'center', halign=>'left', },
outline=>'000000',
features=>'legend',
back=>{ fountain=>'linear',
xa_ratio=>0, ya_ratio=>0,
xb_ratio=>1.0, yb_ratio=>1.0,
segments=>Imager::Fountain->simple
( positions=>[0, 1],
colors=>[ NC('80FF80'), NC('8080FF') ]) }
); |
![]() |
// this uses different data
my $img3 = $pie->draw(data=>\@data, labels=>\@labels,
font=>$font, style=>'fount_lin',
features=>[ 'legend', 'labelspconly', ],
legend=>{ valign=>'center' }); |