| 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
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | classmethod extra_params () { [qw(na_rm)] } | ||||||||||||||||||||||||||
|
Subroutine
extra_params: not called CC=3 SCAR=22.6
Pod
undocumented
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
@_ > 0 and @_ % 2
MC/DC0%0/2
@_ > 0 and @_ % 2
@_ > 0
@_ % 2
Truth table0%0/3
A and B
A= @_ > 0B= @_ % 2
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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())
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())
| |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 0 | my $height; | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( $data->exists('height') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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())
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())
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||