| 1 | package Google::Chart::Type::Map; | ||
| 2 | use Moose; | ||
| 3 | use Moose::Util::TypeConstraints; | ||
| 4 | use namespace::clean -except => qw(meta); | ||
| 5 | |||
| 6 | extends 'Google::Chart'; | ||
| 7 | |||
| 8 | with qw( | ||
| 9 | Google::Chart::WithData | ||
| 10 | Google::Chart::WithSolidFill | ||
| 11 | ); | ||
| 12 | |||
| 13 | has area => ( | ||
| 14 | is => 'ro', | ||
| 15 | isa => enum([ qw(africa asia europe middle_east south_america usa world) ]), | ||
| 16 | required => 1, | ||
| 17 | default => 'world', | ||
| 18 | ); | ||
| 19 | |||
| 20 | has codes => ( | ||
| 21 | is => 'ro', | ||
| 22 | isa => 'ArrayRef', | ||
| 23 | predicate => 'has_codes', | ||
| 24 | ); | ||
| 25 | |||
| 26 | has colors => ( | ||
| 27 | is => 'ro', | ||
| 28 | isa => 'ArrayRef', | ||
| 29 | predicate => 'has_colors', | ||
| 30 | ); | ||
| 31 | |||
| 32 | sub _build_type { 't' } | ||
| 33 | |||
| 34 | around prepare_query => sub { | ||
| 35 | my ($next, $self, @args) = @_; | ||
| 36 | |||
| 37 | my @query = $next->($self, @args); | ||
| 38 | |||
| 39 | push @query, (chtm => $self->area); | ||
| 40 | if ($self->has_colors) { | ||
| 41 | push @query, (chco => join(',', @{ $self->colors } )); | ||
| 42 | } | ||
| 43 | if ($self->has_codes) { | ||
| 44 | push @query, (chld => join('', @{ $self->codes } )); | ||
| 45 | } | ||
| 46 | |||
| 47 | return @query; | ||
| 48 | }; | ||
| 49 | |||
| 50 | __PACKAGE__->meta->make_immutable(); | ||
| 51 | |||
| 52 | 1; |