| 1 | |||
| 2 | package Google::Chart::Type::Venn; | ||
| 3 | use Moose; | ||
| 4 | use Moose::Util::TypeConstraints; | ||
| 5 | use namespace::clean -except => qw(meta); | ||
| 6 | |||
| 7 | extends 'Google::Chart'; | ||
| 8 | with qw( | ||
| 9 | Google::Chart::WithData | ||
| 10 | Google::Chart::WithGrid | ||
| 11 | Google::Chart::WithLinearGradientFill | ||
| 12 | Google::Chart::WithLinearStripe | ||
| 13 | Google::Chart::WithSolidFill | ||
| 14 | ); | ||
| 15 | |||
| 16 | has legend => ( | ||
| 17 | is => 'ro', | ||
| 18 | isa => 'ArrayRef', | ||
| 19 | ); | ||
| 20 | |||
| 21 | has legend_position => ( | ||
| 22 | is => 'ro', | ||
| 23 | isa => enum([ qw(b t r l) ]), | ||
| 24 | ); | ||
| 25 | |||
| 26 | has colors => ( | ||
| 27 | is => 'ro', | ||
| 28 | isa => 'ArrayRef', | ||
| 29 | ); | ||
| 30 | |||
| 31 | sub _build_type { 'v' }; | ||
| 32 | |||
| 33 | around prepare_query => sub { | ||
| 34 | my ($next, $self, @args) = @_; | ||
| 35 | my @query = $next->($self, @args); | ||
| 36 | |||
| 37 | my $legends = $self->legend; | ||
| 38 | if ($legends) { | ||
| 39 | push @query, (chdl => join('|', @$legends)); | ||
| 40 | } | ||
| 41 | |||
| 42 | my $position = $self->legend_position; | ||
| 43 | if ($position) { | ||
| 44 | push @query, (chdlp => $position); | ||
| 45 | } | ||
| 46 | |||
| 47 | my $colors = $self->colors; | ||
| 48 | if ($colors) { | ||
| 49 | push @query, (chco => join(',', @$colors)); | ||
| 50 | } | ||
| 51 | |||
| 52 | return @query; | ||
| 53 | }; | ||
| 54 | |||
| 55 | __PACKAGE__->meta->make_immutable; | ||
| 56 | |||
| 57 | 1; | ||
| 58 | |||
| 59 | __END__ |