| 1 | # $Id$ | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Google::Chart::Marker; | ||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use constant parameter_name => 'chm'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | with 'Google::Chart::QueryComponent::Simple'; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | has 'markerset' => ( | ||||||||||||||||||||||||||||
| 12 | is => 'rw', | ||||||||||||||||||||||||||||
| 13 | isa => 'ArrayRef[Google::Chart::Marker::Item]', | ||||||||||||||||||||||||||||
| 14 | required => 1, | ||||||||||||||||||||||||||||
| 15 | default => sub { | ||||||||||||||||||||||||||||
| 16 | [ Google::Chart::Marker::Item->new ] ; | ||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | __PACKAGE__->meta->make_immutable; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | no Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 26 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 27 | 0 | my @markerset; | |||||||||||||||||||||||||||
| 28 | my @markerargs; | ||||||||||||||||||||||||||||
| 29 | 0 | my %args; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if (@_ == 1 && ref $_[0] eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 32 | 0 | @markerargs = @{$_[0]}; | |||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||
| 34 | 0 | %args = @_; | |||||||||||||||||||||||||||
| 35 | 0 | my $arg = delete $args{markerset}; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (ref $arg eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 37 | 0 | @markerargs = @{ $arg }; | |||||||||||||||||||||||||||
| 38 | } elsif (ref $arg eq 'HASH') { | ||||||||||||||||||||||||||||
| 39 | 0 | @markerargs = ( $arg ); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | @markerargs = ( {} ) unless @markerargs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | foreach my $marker ( @markerargs ) { | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (! Scalar::Util::blessed $marker) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | $marker = Google::Chart::Marker::Item->new($marker) | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 0 | push @markerset, $marker; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | return { %args, markerset => \@markerset }; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub parameter_value { | ||||||||||||||||||||||||||
|
Subroutine
parameter_value: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 57 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | return join ('|', | ||||||||||||||||||||||||||||
| 59 | 0 | map {$_->as_string} @{$self->markerset} | |||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | package # hide from PAUSE | ||||||||||||||||||||||||||||
| 64 | Google::Chart::Marker::Item; | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 1 | ▶ | use Google::Chart::Types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | use Google::Chart::Color; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | coerce 'Google::Chart::Marker::Item' | ||||||||||||||||||||||||||||
| 71 | => from 'HashRef' | ||||||||||||||||||||||||||||
| 72 | => via { | ||||||||||||||||||||||||||||
| 73 | Google::Chart::Marker::Item->new(%{$_}); | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | ; | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | coerce 'Google::Chart::Marker::Item' | ||||||||||||||||||||||||||||
| 78 | => from 'ArrayRef' | ||||||||||||||||||||||||||||
| 79 | => via { | ||||||||||||||||||||||||||||
| 80 | Google::Chart::Marker::Item->new(%{$_}); | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | ; | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | enum 'Google::Chart::Marker::Item::Type' => ( | ||||||||||||||||||||||||||||
| 85 | 'a', # arrow | ||||||||||||||||||||||||||||
| 86 | 'c', # corrs | ||||||||||||||||||||||||||||
| 87 | 'd', # diamond | ||||||||||||||||||||||||||||
| 88 | 'o', # circle | ||||||||||||||||||||||||||||
| 89 | 's', # square | ||||||||||||||||||||||||||||
| 90 | 't', # text | ||||||||||||||||||||||||||||
| 91 | 'v', # vertical line from x-axis to the data point | ||||||||||||||||||||||||||||
| 92 | 'V', # vertical line to the top of the chart | ||||||||||||||||||||||||||||
| 93 | 'h', # horizontal line across | ||||||||||||||||||||||||||||
| 94 | 'x', # x shape | ||||||||||||||||||||||||||||
| 95 | 'D', # Line and bar chart line styles | ||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | has 'marker_type' => ( | ||||||||||||||||||||||||||||
| 99 | is => 'rw', | ||||||||||||||||||||||||||||
| 100 | isa => 'Google::Chart::Marker::Item::Type', | ||||||||||||||||||||||||||||
| 101 | required => 1, | ||||||||||||||||||||||||||||
| 102 | default => 'o' | ||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | has 'color' => ( | ||||||||||||||||||||||||||||
| 106 | is => 'rw', | ||||||||||||||||||||||||||||
| 107 | isa => 'Google::Chart::Color::Data', | ||||||||||||||||||||||||||||
| 108 | required => 1, | ||||||||||||||||||||||||||||
| 109 | # XXX - Hack (for some reason moose didn't like a plain '000000') | ||||||||||||||||||||||||||||
| 110 | # will investigate later | ||||||||||||||||||||||||||||
| 111 | default => sub { return '000000' }, | ||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | has 'dataset' => ( | ||||||||||||||||||||||||||||
| 115 | is => 'rw', | ||||||||||||||||||||||||||||
| 116 | isa => 'Int', | ||||||||||||||||||||||||||||
| 117 | required => 1, | ||||||||||||||||||||||||||||
| 118 | default => 0, | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | has 'datapoint' => ( | ||||||||||||||||||||||||||||
| 122 | is => 'rw', | ||||||||||||||||||||||||||||
| 123 | isa => 'Num', | ||||||||||||||||||||||||||||
| 124 | required => 1, | ||||||||||||||||||||||||||||
| 125 | default => -1, | ||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | has 'size' => ( | ||||||||||||||||||||||||||||
| 129 | is => 'rw', | ||||||||||||||||||||||||||||
| 130 | isa => 'Num', | ||||||||||||||||||||||||||||
| 131 | required => 1, | ||||||||||||||||||||||||||||
| 132 | default => 5, | ||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | has 'priority' => ( | ||||||||||||||||||||||||||||
| 136 | is => 'rw', | ||||||||||||||||||||||||||||
| 137 | isa => 'Int', | ||||||||||||||||||||||||||||
| 138 | required => 1, | ||||||||||||||||||||||||||||
| 139 | default => 0, | ||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | __PACKAGE__->meta->make_immutable; | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | no Moose; | ||||||||||||||||||||||||||||
| 145 | no Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub as_string { | ||||||||||||||||||||||||||||
| 148 | my $self = shift; | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | return join(',', | ||||||||||||||||||||||||||||
| 151 | map { $self->$_ } qw(marker_type color dataset datapoint size priority) ); | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 1; | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | __END__ | ||||||||||||||||||||||||||||