| 1 | package Google::Chart::Type::GoogleOMeter; | ||
| 2 | use Moose; | ||
| 3 | use namespace::clean -except => qw(meta); | ||
| 4 | |||
| 5 | extends 'Google::Chart'; | ||
| 6 | |||
| 7 | with qw( | ||
| 8 | Google::Chart::WithData | ||
| 9 | ); | ||
| 10 | |||
| 11 | has label => ( | ||
| 12 | is => 'ro', | ||
| 13 | isa => 'Str', | ||
| 14 | predicate => 'has_label' | ||
| 15 | ); | ||
| 16 | |||
| 17 | has colors => ( | ||
| 18 | is => 'ro', | ||
| 19 | isa => 'ArrayRef', | ||
| 20 | lazy_build => 1, | ||
| 21 | ); | ||
| 22 | |||
| 23 | sub _build_colors { [] } | ||
| 24 | sub _build_type { 'gom' } | ||
| 25 | |||
| 26 | around prepare_query => sub { | ||
| 27 | my ($next, $self, @args) = @_; | ||
| 28 | |||
| 29 | my @query = $next->($self, @args); | ||
| 30 | if ($self->has_label) { | ||
| 31 | push @query, (chl => $self->label); | ||
| 32 | } | ||
| 33 | |||
| 34 | my $colors = $self->colors; | ||
| 35 | if (@$colors > 0) { | ||
| 36 | push @query, (chco => join(',', @$colors)); | ||
| 37 | } | ||
| 38 | return @query; | ||
| 39 | }; | ||
| 40 | |||
| 41 | __PACKAGE__->meta->make_immutable(); | ||
| 42 | |||
| 43 | 1; | ||
| 44 | |||
| 45 | __END__ |