Chart/GGPlot/Position/Dodge.pm

filter: Statementstmt 47.1% 25 / 53 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 3 totaltotal 34.0% 30 / 88 CC 10 SCAR 26.3
CC
10
Cov
35%
setup_data
30.0
setup_params
20.0
compute_panel
12.0
CRAP 13.8
« Chart/GGPlot/Geom/Boxplot.pm ↑ Summary Chart/GGPlot/Position/Util.pm »
1 package Chart::GGPlot::Position::Dodge;
2  
3 # ABSTRACT: Position for 'dodge'
4  
5 6 ▶use Chart::GGPlot::Class;
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 List::AllUtils qw(count_by);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Types::Standard qw(Enum);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 ▶use Chart::GGPlot::Position::Util qw(collide pos_dodge);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 6 my $PreserveEnum = Enum [qw(total single)];
17  
18 6 has width => ( is => 'ro' );
19 6 has preserve => ( is => 'ro', isa => $PreserveEnum, default => 'total' );
20  
21 6 with qw(Chart::GGPlot::Position);
22  
23 0 ▶method setup_data ($data, $params) {
Subroutine setup_data: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for method setup_data (expected 3, got ' . @_ . ')') 0 0 0
@_ > 3 and Function::Parameters::_croak('Too many arguments for method setup_data (expected 3, got ' . @_ . ')') 0 0 0
24 0 ▶ if ( not $data->exists('x')
Branch: 1 branch
BranchTrueFalseTotal
if (not $data->exists("x") and &List::AllUtils::all(sub { $data->exists($_); } , "xmin", "xmax")) 0 0 0
Condition0%0/3
not $data->exists("x") and &List::AllUtils::all(sub { $data->exists($_); } , "xmin", "xmax")
!ll&&!rl&&r
000
MC/DC0%0/2
not $data->exists("x") and &List::AllUtils::all(sub { $data->exists($_); } , "xmin", "xmax")
not $data->exists("x") &List::AllUtils::all(sub { $data->exists($_); } , "xmin", "xmax")
Truth table0%0/3
not(A) and B
A= not $data->exists("x")B= &List::AllUtils::all(sub { $data->exists($_); } , "xmin", "xmax")
ABresult
0X0
100
111
25 0 ▶ and List::AllUtils::all { $data->exists($_) } qw(xmin xmax) )
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 {
27 0 $data->set( 'x', ( $data->at('xmin') + $data->at('xmax') ) / 2 );
28 }
29 0 return $data;
30 6 }
31  
32 0 ▶method setup_params ($data) {
Subroutine setup_params: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for method setup_params (expected 2, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method setup_params (expected 2, got ' . @_ . ')') 0 0 0
33 0 my $splitted = $data->split( $data->at('PANEL') );
34 0 my $n;
35 0 ▶ if ( $self->preserve ne 'total' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->preserve ne "total") 0 0 0
36 $n = List::AllUtils::max(
37 $splitted->values->map(
38 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 ▶ my %count = count_by { $_ } $_->at('xmin')->flatten;
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 return List::AllUtils::max( values(%count), 1 );
41 }
42 0 )->flatten
43 );
44 }
45  
46 0 return { width => $self->width, n => $n };
47 6 }
48  
49 0 ▶method compute_panel ($data, $params, $scales) {
Subroutine compute_panel: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 4 and Function::Parameters::_croak('Too few arguments for method compute_panel (expected 4, got ' . @_ . ')') 0 0 0
@_ > 4 and Function::Parameters::_croak('Too many arguments for method compute_panel (expected 4, got ' . @_ . ')') 0 0 0
50 return collide(
51 $data, $params->{width}, 'position_dodge', \&pos_dodge,
52 n => $params->{n},
53 0 check_width => false
54 );
55 6 }
56  
57 6 __PACKAGE__->meta->make_immutable;
58  
59 6 1;
60  
61 __END__
« Chart/GGPlot/Geom/Boxplot.pm ↑ Summary Chart/GGPlot/Position/Util.pm »