— |
coerce 'Google::Chart::Title'
=> from 'HashRef'
=> via {
Google::Chart::Title->new( %$_ );
}
;
has 'text' => (
is => 'rw' ,
isa => 'Str' ,
required => 1,
);
has 'color' => (
is => 'rw' ,
isa => 'Google::Chart::Color' ,
);
has 'fontsize' => (
is => 'rw' ,
isa => 'Num'
);
__PACKAGE__->meta->make_immutable;
no Moose;
sub as_query {
my $self = shift ;
my $text = $self ->text;
$text =~ s/\r?\n/|/gsm;
my %data = (
chtt => $text
);
my $color = $self ->color;
my $fontsize = $self ->fontsize;
if ( defined $color || defined $fontsize ) {
$data {chts} = join ( ',' ,
defined $color ? $color : '' ,
defined $fontsize ? $fontsize : ''
);
}
return wantarray ? %data :
join ( '&' , map { "$_=$data{$_}" } keys %data );
}
1;
|