Chart/GGPlot/Geom/Tile.pm

filter: Statementstmt 46.8% 37 / 79 Branchbran 6.6% 2 / 30 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 4 totaltotal 33.3% 47 / 141 CC 19 SCAR 33.2
CC
19
Cov
33%
__ANON__
56.0
setup_data
56.0
require_aes
9.6
CRAP 27.7
« Chart/GGPlot/Backend/Plotly/Util.pm ↑ Summary Chart/GGPlot/Util/Scales.pm »
1 package Chart::GGPlot::Geom::Tile;
2  
3 # ABSTRACT: Class for tile geom
4  
5 5 ▶use Chart::GGPlot::Class qw(:pdl);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use MooseX::Singleton;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 with qw(Chart::GGPlot::Geom);
10  
11 5 our $VERSION = '0.002003'; # VERSION
12  
13 5 ▶use Chart::GGPlot::Aes;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use Chart::GGPlot::Layer;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use Chart::GGPlot::Util qw(NA resolution);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use Chart::GGPlot::Util::Pod qw(layer_func_pod);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 has '+default_aes' => (
19 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 Chart::GGPlot::Aes->new(
21 color => NA(),
22 fill => PDL::SV->new( ['grey20'] ),
23 size => pdl(0.1),
24 linetype => PDL::SV->new( ['solid'] ),
25 alpha => NA(),
26 width => NA(),
27 height => NA(),
28 );
29 }
30 5 );
31  
32 0 ▶classmethod require_aes () { [qw(x y)] }
Subroutine require_aes: not called CC=3 SCAR=22.6
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod require_aes (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for classmethod require_aes (expected 1, got ' . @_ . ')') 0 0 0
33 0 ▶classmethod extra_params () { [qw(na_rm)] }
Subroutine extra_params: not called CC=3 SCAR=22.6
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod extra_params (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for classmethod extra_params (expected 1, got ' . @_ . ')') 0 0 0
34  
35 5 my $geom_tile_pod = layer_func_pod(<<'EOT');
36  
37 geom_tile(:$mapping=undef, :$data=undef, :$stat='count',
38 :$position='stack', :$width=undef,
39 :$na_rm=false, :$show_legend=undef, :$inherit_aes=true,
40 %rest)
41  
42 C<geom_tile()> uses the center of the tile and its size
43 (aesthetics C<x>, C<y>, C<width> and C<height>) to define rectangles.
44  
45 Arguments:
46  
47 =over 4
48  
49 %TMPL_COMMON_ARGS%
50  
51 =back
52  
53 EOT
54  
55 0 ▶my $geom_tile_code = fun(
Subroutine __ANON__: not called CC=7 SCAR=40.3
Branch: 1 branch
BranchTrueFalseTotal
@_ > 0 and @_ % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun (anon)") 0 0 0
Condition0%0/3
@_ > 0 and @_ % 2
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 0 and @_ % 2
@_ > 0 @_ % 2
Truth table0%0/3
A and B
A= @_ > 0B= @_ % 2
ABresult
0X0
100
111
56 :$mapping = undef, :$data = undef,
57 :$stat = 'identity', :$position = 'identity',
58 :$na_rm = false, :$show_legend = undef, :$inherit_aes = true,
59 %rest)
60 0 ▶{
Branch: 4 branches
BranchTrueFalseTotal
exists $rest{'stat'} ? : 0 0 0
exists $rest{'position'} ? : 0 0 0
exists $rest{'na_rm'} ? : 0 0 0
exists $rest{'inherit_aes'} ? : 0 0 0
61 0 return Chart::GGPlot::Layer->new(
62 data => $data,
63 mapping => $mapping,
64 stat => $stat,
65 geom => 'tile',
66 position => $position,
67 show_legend => $show_legend,
68 inherit_aes => $inherit_aes,
69 params => {
70 na_rm => $na_rm,
71 %rest
72 },
73 );
74 5 };
75  
76 5 ▶classmethod ggplot_functions () {
Subroutine ggplot_functions: called CC=3 SCAR=11.3
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod ggplot_functions (expected 1, got ' . @_ . ')') 0 5 5
@_ > 1 and Function::Parameters::_croak('Too many arguments for classmethod ggplot_functions (expected 1, got ' . @_ . ')') 0 5 5
77 return [
78 {
79 5 name => 'geom_tile',
80 code => $geom_tile_code,
81 pod => $geom_tile_pod,
82 },
83 ];
84 5 }
85  
86 0 ▶method setup_data ($data, $params) {
Subroutine setup_data: not called CC=7 SCAR=40.3
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
87 0 my $x = $data->at('x');
88 0 my $y = $data->at('y');
89 0 my $width;
90 0 ▶ if ( $data->exists('width') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->exists('width')) { } 0 0 0
91 0 $width = $data->delete('width');
92 }
93 else {
94 0 ▶ $width = $params->at('width') // resolution( $x, false );
Condition0%0/3
$params->at("width") // resolution($x, &false())
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->at("width") // resolution($x, &false())
$params->at("width") resolution($x, &false())
Truth table0%0/3
A // B
A= $params->at("width")B= resolution($x, &false())
ABresult
1X1
011
000
95 }
96 0 my $height;
97 0 ▶ if ( $data->exists('height') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->exists('height')) { } 0 0 0
98 0 $height = $data->delete('height');
99 }
100 else {
101 0 ▶ $height = $params->at('height') // resolution( $y, false );
Condition0%0/3
$params->at("height") // resolution($y, &false())
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->at("height") // resolution($y, &false())
$params->at("height") resolution($y, &false())
Truth table0%0/3
A // B
A= $params->at("height")B= resolution($y, &false())
ABresult
1X1
011
000
102 }
103  
104 0 $data->set('xmin', $x - $width / 2);
105 0 $data->set('xmax', $x + $width / 2);
106 0 $data->set('ymin', $y - $height / 2);
107 0 $data->set('ymax', $y + $height / 2);
108  
109 0 return $data;
110 5 }
111  
112 5 __PACKAGE__->meta->make_immutable;
113  
114 5 1;
115  
116 __END__
« Chart/GGPlot/Backend/Plotly/Util.pm ↑ Summary Chart/GGPlot/Util/Scales.pm »