my $chart = Imager::Graph::Sub_class->new;
my $img = $chart->draw(data=> \@data, ...)
or die $chart->error;
+ $img->write(file => 'image.png');
=head1 DESCRIPTION
use Imager qw(:handy);
use Imager::Fountain;
-$VERSION = '0.06';
+$VERSION = '0.07';
# the maximum recursion depth in determining a color, fill or number
use constant MAX_DEPTH => 10;
my $graph_data = $self->{'graph_data'} || [];
push @$graph_data, { data => $data_ref, series_name => $series_name };
+ if (defined $series_name) {
+ push @{$self->{'labels'}}, $series_name;
+ }
$self->{'graph_data'} = $graph_data;
return;
=item error
-Returns an error message. Only value if the draw() method returns false.
+Returns an error message. Only valid if the draw() method returns false.
=cut
The C<style> parameter will selects a basic color set, and possibly
sets other related parameters. See L</"STYLES">.
- my $font = Imager::Font->new(file => 'Im_ugly.ttf');
+ my $font = Imager::Font->new(file => 'ImUgly.ttf');
my $img = $chart->draw(
data => \@data,
font => $font,
(
back=> 'lookup(bg)',
line=> 'lookup(fg)',
+ aa => 1,
text=>{
color => 'lookup(fg)',
font => 'lookup(font)',
size => 14,
+ aa => 'lookup(aa)',
},
title=>{
color => 'lookup(text.color)',
halign => 'center',
valign => 'top',
size => 'scale(text.size,2.0)',
+ aa => 'lookup(text.aa)',
},
legend =>{
color => 'lookup(text.color)',
font => 'lookup(text.font)',
+ aa => 'lookup(text.aa)',
size => 'lookup(text.size)',
patchsize => 'scale(legend.size,0.9)',
patchgap => 'scale(legend.patchsize,0.3)',
outside => 'lookup(callout.size)',
leadlen => 'scale(0.8,callout.size)',
gap => 'scale(callout.size,0.3)',
+ aa => 'lookup(text.aa)',
+ lineaa => 'lookup(lineaa)',
},
label => {
font => 'lookup(text.font)',
pad => 'scale(label.size,0.2)',
pcformat => sub { sprintf "%s (%.0f%%)", $_[0], $_[1] },
pconlyformat => sub { sprintf "%.1f%%", $_[0] },
+ aa => 'lookup(text.aa)',
+ lineaa => 'lookup(lineaa)',
},
dropshadow => {
fill => { solid => Imager::Color->new(0, 0, 0, 96) },
},
outline => {
line =>'lookup(line)',
+ lineaa => 'lookup(lineaa)',
},
size=>256,
width=>'scale(1.5,size)',
height=>'lookup(size)',
+
+ # yes, the handling of fill and line AA is inconsistent, lack of
+ # forethought, unfortunately
+ fill => {
+ aa => 'lookup(aa)',
+ },
+ lineaa => 'lookup(aa)',
);
=item _error($message)
pie =>{
blur=>undef,
},
+ aa => 0,
},
fount_lin =>
{
colors => [
qw(FF0000 00FF00 0000FF C0C000 00C0C0 FF00FF)
],
+ line_markers =>[
+ { shape => 'circle', radius => 4 },
+ { shape => 'square', radius => 4 },
+ { shape => 'diamond', radius => 4 },
+ { shape => 'triangle', radius => 4 },
+ { shape => 'x', radius => 4 },
+ { shape => 'plus', radius => 4 },
+ ],
back=>{ fountain=>'linear',
xa_ratio=>0, ya_ratio=>0,
xb_ratio=>1.0, yb_ratio=>1.0,
xa_ratio => 0, ya_ratio=>0, xb_ratio=>1.0, yb_ratio=>1.0,
segments => Imager::Fountain->simple(
positions=>[0, 1],
- colors=>[ NC('FFFFFF'), NC('E6E2AF') ]),
+ colors=>[ NC('EFEDCF'), NC('E6E2AF') ]),
},
{
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('FFFFFF'), NC('A7A37E') ]),
+ colors=>[ NC('DCD7AB'), NC('A7A37E') ]),
},
{
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('FFFFFF'), NC('80B4A2') ]),
+ colors=>[ NC('B2E5D4'), NC('80B4A2') ]),
},
{
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('FFFFFF'), NC('046380') ]),
+ colors=>[ NC('7aaab9'), NC('046380') ]),
},
{
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('FFFFFF'), NC('877EA7') ]),
+ colors=>[ NC('c3b8e9'), NC('877EA7') ]),
},
{
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('FFFFFF'), NC('67A35E') ]),
+ colors=>[ NC('A3DF9A'), NC('67A35E') ]),
},
{
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('FFFFFF'), NC('B4726F') ]),
+ colors=>[ NC('E19C98'), NC('B4726F') ]),
},
],
colors => [
};
+$styles{'ocean_flat'} = {
+ fills=>
+ [
+ qw(E6E2AF A7A37E 80B4A2 046380 877EA7 67A35E B4726F)
+ ],
+ colors => [
+ qw(E6E2AF A7A37E 80B4A2 046380 877EA7 67A35E B4726F)
+ ],
+ fg=>'000000',
+ negative_bg=>'EEEEEE',
+ bg=>'FFFFFF',
+ features=>{ dropshadow=>1 },
+
+};
+
+
=item $self->_style_setup(\%opts)
Uses the values from %opts to build a customized hash describing the
Returns an empty list on failure.
+Returns the following attributes: font, color, size, aa, sizew
+(optionally)
+
=cut
sub _text_style {
$work{size} = $self->_get_number("$name.size");
$work{sizew} = $self->_get_number("$name.sizew")
if $work{sizew};
+ $work{aa} = $self->_get_number("$name.aa");
%work;
}
return @bbox[0..3];
}
+=item _line_style($name)
+
+Return parameters suitable for calls to Imager's line(), polyline(),
+and box() methods.
+
+For now this returns only color and aa parameters, but future releases
+of Imager may support extra parameters.
+
+=cut
+
+sub _line_style {
+ my ($self, $name) = @_;
+
+ my %line;
+ $line{color} = $self->_get_color("$name.line")
+ or return;
+ $line{aa} = $self->_get_number("$name.lineaa");
+ defined $line{aa} or $line{aa} = $self->_get_number("aa");
+
+ return %line;
+}
+
sub _align_box {
my ($self, $box, $chart_box, $name) = @_;