Chart/GGPlot/Geom.pm

filter: Statementstmt 80.8% 59 / 73 Branchbran 39.2% 11 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 6 totaltotal 67.2% 80 / 119 CC 18 SCAR 20.1
CC
18
Cov
69%
use_defaults
14.4
handle_na
12.0
aesthetics
3.1
CRAP 7.4
« Chart/GGPlot/Coord.pm ↑ Summary Chart/GGPlot/Trans/Functions.pm »
1 package Chart::GGPlot::Geom;
2  
3 # ABSTRACT: The geom role
4  
5 6 ▶use Chart::GGPlot::Role qw(:pdl);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 our $VERSION = '0.002003'; # VERSION
9  
10 6 ▶use Data::Frame::Util qw(guess_and_convert_to_pdl);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Types::Standard qw(ArrayRef CodeRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 ▶use Chart::GGPlot::Aes;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use Chart::GGPlot::Util qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 6 with qw(
17 Chart::GGPlot::HasRequiredAes
18 Chart::GGPlot::HasDefaultAes
19 Chart::GGPlot::HasNonMissingAes
20 Chart::GGPlot::HasParams
21 Chart::GGPlot::HasCollectibleFunctions
22 );
23  
24 26 ▶classmethod optional_aes() { [] }
Subroutine optional_aes: called CC=3 SCAR=11.2
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod optional_aes (expected 1, got ' . @_ . ')') 0 26 26
@_ > 1 and Function::Parameters::_croak('Too many arguments for classmethod optional_aes (expected 1, got ' . @_ . ')') 0 26 26
25  
26 3 ▶method setup_data ($data, $params) { $data }
Subroutine setup_data: called CC=3 SCAR=11.2
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for method setup_data (expected 3, got ' . @_ . ')') 0 3 3
@_ > 3 and Function::Parameters::_croak('Too many arguments for method setup_data (expected 3, got ' . @_ . ')') 0 3 3
27  
28 # Renders a single legend key.
29 0 ▶sub draw_key { return draw_key_point(@_) }
Subroutine draw_key: not called CC=1 SCAR=6.9
Pod undocumented
30  
31 0 ▶method handle_na ( $data, $params ) {
Subroutine handle_na: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for method handle_na (expected 3, got ' . @_ . ')') 0 0 0
@_ > 3 and Function::Parameters::_croak('Too many arguments for method handle_na (expected 3, got ' . @_ . ')') 0 0 0
32 return remove_missing(
33 $data,
34 na_rm => $params->at('na_rm'),
35 0 vars => [ @{ $self->required_aes }, @{ $self->non_missing_aes } ],
36 name => $self->name
37 );
38 6 }
39  
40 # Combine data with defaults and set aesthetics from parameters
41 6 ▶method use_defaults ( $data, $params = {} ) {
Subroutine use_defaults: called CC=10 SCAR=26.7
Pod undocumented
Branch: 3 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for method use_defaults (expected 2, got ' . @_ . ')') 0 6 6
@_ > 3 and Function::Parameters::_croak('Too many arguments for method use_defaults (expected 3, got ' . @_ . ')') 0 6 6
@_ < 2 and $params = {} 0 6 6
42 6 ▶ if ( $data->isempty ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->isempty) { } 0 6 6
43  
44 # create $data from $self->default_aes
45 #$data = $self->default_aes->get();
46 }
47 else {
48 # Fill in missing aesthetics with their defaults
49 6 my $missing_aes = $self->default_aes->names->setdiff( $data->names );
50  
51 6 for my $name ( sort @$missing_aes ) {
52 31 my $default = $self->default_aes->at($name);
53 31 ▶ next unless defined $default;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $default 0 31 31
54 31 $data->set( $name, $default );
55 }
56 }
57  
58 # Override mappings with params
59 6 my $aes_names = $self->aesthetics->intersect( $params->keys );
60 6 my $aes_params = $params->hslice($aes_names);
61 6 for my $aes (@$aes_names) {
62 0 my $val = $aes_params->at($aes);
63 0 ▶ unless ($val->$_DOES('PDL')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($val->$Chart::GGPlot::Geom::_DOES("PDL")) 0 0 0
64 0 $val = guess_and_convert_to_pdl($val);
65 0 $aes_params->set($aes, $val);
66 }
67 }
68 6 Chart::GGPlot::Aes->check_aesthetics( $aes_params, $data->nrow );
69 6 for my $aes (@$aes_names) {
70 0 $data->set($aes, $aes_params->at($aes));
71 }
72 6 return $data;
73 6 }
74  
75 26 ▶method aesthetics () {
Subroutine aesthetics: called CC=3 SCAR=11.3
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method aesthetics (expected 1, got ' . @_ . ')') 0 26 26
@_ > 1 and Function::Parameters::_croak('Too many arguments for method aesthetics (expected 1, got ' . @_ . ')') 0 26 26
76 return [
77 (
78 26 $self->required_aes->union( $self->default_aes->keys )->flatten,
79 $self->optional_aes->flatten, "group"
80 )
81 ];
82 6 }
83  
84 6 1;
85  
86 __END__
« Chart/GGPlot/Coord.pm ↑ Summary Chart/GGPlot/Trans/Functions.pm »