Chart/GGPlot/Labeller.pm

filter: Statementstmt 85.5% 136 / 159 Branchbran 49.0% 49 / 100 Conditioncond 17.3% 4 / 23 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 93.9% 31 / 33 Podpod 60.0% 3 / 5 totaltotal 66.7% 223 / 334 CC 76 SCAR 25.4
CC
76
Cov
67%
as_labeller
44.7
__ANON__
33.7
_resolve_labeller
32.8
CRAP 12.7
« Chart/GGPlot/Layer.pm ↑ Summary Chart/GGPlot/Facet.pm »
1 package Chart::GGPlot::Labeller;
2  
3 # ABSTRACT: Labeller functions for facets
4  
5 1 ▶use Chart::GGPlot::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 our $VERSION = '0.002003'; # VERSION
9  
10 13 ▶use Data::Munge qw(elem);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Types::Standard qw(CodeRef HashRef InstanceOf Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use List::AllUtils qw(each_arrayref pairmap pairwise);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Data::Frame::Types qw(DataFrame);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Chart::GGPlot::Util qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 use overload
19 14 ▶ '&{}' => sub { $_[0]->func },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1 fallback => 1;
21  
22 has func => ( is => 'ro', isa => CodeRef, required => 1 );
23  
24 24 ▶around BUILDARGS( $orig, $class : @rest ) {
Subroutine :around: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for around BUILDARGS (expected 2, got ' . @_ . ')') 10 32 42
25 24 my %params;
26 24 ▶ if ( @rest == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rest == 1) { } 22 4 26
27 %params =
28 Ref::Util::is_plain_coderef( $rest[0] )
29 ? ( func => $rest[0] )
30 0 ▶ : %{ $rest[0] };
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_plain_coderef($rest[0]) ? : 23 1 24
31 }
32 else {
33 2 %params = @rest;
34 }
35 24 return $class->$orig(%params);
36 }
37  
38 5 ▶classmethod _collapse_labels_lines ($labeller_out) {
Subroutine _collapse_labels_lines: called CC=3 SCAR=11.2
Branch: 2 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for classmethod _collapse_labels_lines (expected 2, got ' . @_ . ')') 0 5 5
@_ > 2 and Function::Parameters::_croak('Too many arguments for classmethod _collapse_labels_lines (expected 2, got ' . @_ . ')') 0 5 5
39 5 ▶ return $labeller_out->map( sub { join( ', ', @$_ ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
40 }
41  
42 14 ▶classmethod label_value ($multi_line=true) {
Subroutine label_value: called CC=4 SCAR=14.1
Pod undocumented
Branch: 3 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod label_value (expected 1, got ' . @_ . ')') 0 14 14
@_ > 2 and Function::Parameters::_croak('Too many arguments for classmethod label_value (expected 2, got ' . @_ . ')') 0 14 14
@_ < 1 and $multi_line = &true() 1 13 14
43 6 ▶ my $f = fun( DataFrame $labels) {
Subroutine __ANON__: called CC=7 SCAR=20.1
Branch: 3 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') 0 6 6
@_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') 0 6 6
do { package Type::Tiny; builtin::blessed($labels) and do { my $method = $labels->can("DOES") || $labels->can("isa"); $labels->$method("Data::Frame") } } or Function::Parameters::_croak('In fun (anon): parameter 1 ($labels): ' . ${my $v = bless( {"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"compiled_type_constraint" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; do { package Type::Tiny; builtin::blessed($_[0]) and do { my $method = $_[0]->can('DOES') || $_[0]->can('isa'); $_[0]->$method('Data::Frame') } };},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Data/Frame/Types.pm","line" => 20,"package" => "Data::Frame::Types"},"deprecated" => !!0,"display_name" => "DataFrame","exception_class" => "Error::TypeTiny::Assertion","library" => "Data::Frame::Types","name" => "DataFrame","parent" => bless( {"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"frozen" => 1,"name" => "__ANON__","type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 1015,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "ConsumerOf[\"Data::Frame\"]","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Type::Tiny::Role; use warnings; use strict; my $var = $_[1]; my $code = "Scalar::Util::blessed($var) and do { my \$method = $var->can('DOES')||$var->can('isa'); $var->\$method(q[$role]) }"; return "do { use Scalar::Util (); $code }" if $Type::Tiny::AvoidCallbacks; $code;},"name" => "__ANON__","role" => "Data::Frame","uniq" => 76}, 'Type::Tiny::Role' ),"uniq" => 77}, 'Type::Tiny' );$v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"compiled_type_constraint"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"compiled_type_constraint"}; \$v}->get_message($labels)) 6 0 6
44 my $ea = each_arrayref(
45 20 ▶ @{ $labels->names->map( sub { $labels->at($_)->unpdl } ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
46 my $rslt =
47 6 ▶ [ 0 .. $labels->nrow - 1 ]->map( sub { [ $ea->() ] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
48 return (
49 6 ▶ $multi_line
Branch: 1 branch
BranchTrueFalseTotal
$multi_line ? : 0 6 6
50 ? $rslt
51 : $class->_collapse_labels_lines($rslt)
52 );
53 14 };
54 14 return $class->new($f);
55 }
56  
57 6 ▶classmethod label_both ($multi_line=true, $sep=': ') {
Subroutine label_both: called CC=5 SCAR=16.3
Pod undocumented
Branch: 4 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod label_both (expected 1, got ' . @_ . ')') 0 6 6
@_ > 3 and Function::Parameters::_croak('Too many arguments for classmethod label_both (expected 3, got ' . @_ . ')') 4 2 6
@_ < 2 and do { @_ < 1 and $multi_line = &true(); $sep = ": " } 1 3 4
@_ < 1 and $multi_line = &true() 0 6 6
58 24 ▶ my $f = fun( DataFrame $labels) {
Subroutine __ANON__: called CC=7 SCAR=19.9
Branch: 3 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') 0 6 6
@_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') 6 0 6
do { package Type::Tiny; builtin::blessed($labels) and do { my $method = $labels->can("DOES") || $labels->can("isa"); $labels->$method("Data::Frame") } } or Function::Parameters::_croak('In fun (anon): parameter 1 ($labels): ' . ${my $v = bless( {"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"compiled_type_constraint" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; do { package Type::Tiny; builtin::blessed($_[0]) and do { my $method = $_[0]->can('DOES') || $_[0]->can('isa'); $_[0]->$method('Data::Frame') } };},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Data/Frame/Types.pm","line" => 20,"package" => "Data::Frame::Types"},"deprecated" => !!0,"display_name" => "DataFrame","exception_class" => "Error::TypeTiny::Assertion","library" => "Data::Frame::Types","name" => "DataFrame","parent" => bless( {"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"frozen" => 1,"name" => "__ANON__","type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 1015,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "ConsumerOf[\"Data::Frame\"]","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Type::Tiny::Role; use warnings; use strict; my $var = $_[1]; my $code = "Scalar::Util::blessed($var) and do { my \$method = $var->can('DOES')||$var->can('isa'); $var->\$method(q[$role]) }"; return "do { use Scalar::Util (); $code }" if $Type::Tiny::AvoidCallbacks; $code;},"name" => "__ANON__","role" => "Data::Frame","uniq" => 76}, 'Type::Tiny::Role' ),"uniq" => 77}, 'Type::Tiny' );$v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"compiled_type_constraint"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"compiled_type_constraint"}; \$v}->get_message($labels)) 0 2 2
59 2 my $variables = $labels->names;
60 my $ea = each_arrayref(
61 2 ▶ @{ $variables->map( sub { $labels->at($_)->unpdl } ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
62 my $rslt = [ 0 .. $labels->nrow - 1 ]->map(
63 24 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
64 4 my @row_data = $ea->();
65 4 ▶ [ pairwise { join( $sep, $a, $b ) } @$variables, @row_data ];
Subroutine __ANON__: called CC=1 SCAR=0.0
66 }
67 2 );
68 return (
69 2 ▶ $multi_line
Branch: 1 branch
BranchTrueFalseTotal
$multi_line ? : 0 2 2
70 ? $rslt
71 : $class->_collapse_labels_lines($rslt)
72 );
73 6 };
74 10 return $class->new($f);
75 }
76  
77  
78 12 ▶classmethod label_context ($multi_line=true, $sep=': ') {
Subroutine label_context: called CC=5 SCAR=17.1
Pod documented
Branch: 4 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod label_context (expected 1, got ' . @_ . ')') 2 0 2
@_ > 3 and Function::Parameters::_croak('Too many arguments for classmethod label_context (expected 3, got ' . @_ . ')') 1 1 2
@_ < 2 and do { @_ < 1 and $multi_line = &true(); $sep = ": " } 0 4 4
@_ < 1 and $multi_line = &true() 0 4 4
79 0 ▶ my $f = fun( DataFrame $labels) {
Subroutine __ANON__: called CC=7 SCAR=22.2
Branch: 3 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') 4 0 4
@_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') 0 12 12
do { package Type::Tiny; builtin::blessed($labels) and do { my $method = $labels->can("DOES") || $labels->can("isa"); $labels->$method("Data::Frame") } } or Function::Parameters::_croak('In fun (anon): parameter 1 ($labels): ' . ${my $v = bless( {"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"compiled_type_constraint" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; do { package Type::Tiny; builtin::blessed($_[0]) and do { my $method = $_[0]->can('DOES') || $_[0]->can('isa'); $_[0]->$method('Data::Frame') } };},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Data/Frame/Types.pm","line" => 20,"package" => "Data::Frame::Types"},"deprecated" => !!0,"display_name" => "DataFrame","exception_class" => "Error::TypeTiny::Assertion","library" => "Data::Frame::Types","name" => "DataFrame","parent" => bless( {"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"frozen" => 1,"name" => "__ANON__","type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 1015,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "ConsumerOf[\"Data::Frame\"]","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Type::Tiny::Role; use warnings; use strict; my $var = $_[1]; my $code = "Scalar::Util::blessed($var) and do { my \$method = $var->can('DOES')||$var->can('isa'); $var->\$method(q[$role]) }"; return "do { use Scalar::Util (); $code }" if $Type::Tiny::AvoidCallbacks; $code;},"name" => "__ANON__","role" => "Data::Frame","uniq" => 76}, 'Type::Tiny::Role' ),"uniq" => 77}, 'Type::Tiny' );$v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"compiled_type_constraint"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"compiled_type_constraint"}; \$v}->get_message($labels)) 0 12 12
80 return (
81 6 ▶ $labels->length == 1
Branch: 1 branch
BranchTrueFalseTotal
$labels->length == 1 ? : 12 0 12
82 ? $class->label_value($multi_line)->($labels)
83 : $class->label_both( $multi_line, $sep )->($labels)
84 );
85 12 };
86 12 return $class->new($f);
87 }
88  
89  
90 6 ▶classmethod _labeller_by_name ($x, $multi_line) {
Subroutine _labeller_by_name: called CC=5 SCAR=19.3
Branch: 2 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for classmethod _labeller_by_name (expected 3, got ' . @_ . ')') 0 6 6
@_ > 3 and Function::Parameters::_croak('Too many arguments for classmethod _labeller_by_name (expected 3, got ' . @_ . ')') 0 6 6
91 6 state $supported_labeller_names = [qw(value both context)];
92 0 ▶ if ( !Ref::Util::is_ref($x) and elem( $x, $supported_labeller_names ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not Ref::Util::XS::is_ref($x) and elem($x, $supported_labeller_names)) { } 4 2 6
Condition33%1/3
not Ref::Util::XS::is_ref($x) and elem($x, $supported_labeller_names)
!ll&&!rl&&r
0012
MC/DC0%0/2
not Ref::Util::XS::is_ref($x) and elem($x, $supported_labeller_names)
not Ref::Util::XS::is_ref($x) elem($x, $supported_labeller_names)
Truth table33%1/3
not(A) and B
A= not Ref::Util::XS::is_ref($x)B= elem($x, $supported_labeller_names)
ABresult
0X0
100
111
93 0 my $f = "label_$x";
94 0 return $class->$f($multi_line);
95 }
96 else {
97 0 return $x;
98 }
99 }
100  
101 0 ▶classmethod as_labeller ($x, $default='value', $multi_line=true) {
Subroutine as_labeller: called CC=7 SCAR=38.0
Pod documented
Branch: 4 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for classmethod as_labeller (expected 2, got ' . @_ . ')') 4 0 4
@_ > 4 and Function::Parameters::_croak('Too many arguments for classmethod as_labeller (expected 4, got ' . @_ . ')') 6 0 6
@_ < 3 and do { @_ < 2 and $default = "value"; $multi_line = &true() } 0 0 0
@_ < 2 and $default = "value" 0 0 0
102 0 $x = $class->_labeller_by_name( $x, $multi_line );
103 0 $default = $class->_labeller_by_name( $default, $multi_line );
104  
105 0 ▶ if ( $x->$_isa($class) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x->$Chart::GGPlot::Labeller::_isa($class)) { } 0 0 0
elsif (Ref::Util::XS::is_plain_coderef($x)) { } 0 0 0
106 0 return $x->func;
107 }
108 elsif ( Ref::Util::is_plain_coderef($x) ) {
109 0 ▶ my $f = fun( DataFrame $labels) {
Subroutine __ANON__: not called CC=6 SCAR=35.2
Branch: 3 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') 0 0 0
do { package Type::Tiny; builtin::blessed($labels) and do { my $method = $labels->can("DOES") || $labels->can("isa"); $labels->$method("Data::Frame") } } or Function::Parameters::_croak('In fun (anon): parameter 1 ($labels): ' . ${my $v = bless( {"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"compiled_type_constraint" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; do { package Type::Tiny; builtin::blessed($_[0]) and do { my $method = $_[0]->can('DOES') || $_[0]->can('isa'); $_[0]->$method('Data::Frame') } };},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Data/Frame/Types.pm","line" => 20,"package" => "Data::Frame::Types"},"deprecated" => !!0,"display_name" => "DataFrame","exception_class" => "Error::TypeTiny::Assertion","library" => "Data::Frame::Types","name" => "DataFrame","parent" => bless( {"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"frozen" => 1,"name" => "__ANON__","type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 1015,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "ConsumerOf[\"Data::Frame\"]","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Type::Tiny::Role; use warnings; use strict; my $var = $_[1]; my $code = "Scalar::Util::blessed($var) and do { my \$method = $var->can('DOES')||$var->can('isa'); $var->\$method(q[$role]) }"; return "do { use Scalar::Util (); $code }" if $Type::Tiny::AvoidCallbacks; $code;},"name" => "__ANON__","role" => "Data::Frame","uniq" => 76}, 'Type::Tiny::Role' ),"uniq" => 77}, 'Type::Tiny' );$v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"compiled_type_constraint"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"compiled_type_constraint"}; \$v}->get_message($labels)) 0 0 0
110 2 return $default->( $labels->apply($x) );
111 0 };
112 0 return $class->new( func => $f );
113 }
114 else {
115 0 return $default;
116 }
117 }
118  
119 2 ▶classmethod _resolve_labeller ($rows, $cols, $labels) {
Subroutine _resolve_labeller: not called CC=12 SCAR=34.9
Branch: 2 branches
BranchTrueFalseTotal
@_ < 4 and Function::Parameters::_croak('Too few arguments for classmethod _resolve_labeller (expected 4, got ' . @_ . ')') 0 0 0
@_ > 4 and Function::Parameters::_croak('Too many arguments for classmethod _resolve_labeller (expected 4, got ' . @_ . ')') 0 0 0
120 2 ▶ unless ( defined $rows or defined $cols ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rows or defined $cols) 0 0 0
Condition0%0/3
defined $rows or defined $cols
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $rows or defined $cols
defined $rows defined $cols
Truth table0%0/3
A or B
A= defined $rowsB= defined $cols
ABresult
1X1
011
000
121 2 die "Supply one of rows or cols";
122 }
123 2 ▶ if ( ( $labels->$_call_if_can('facet') // '' ) eq 'wrap' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($labels->$Chart::GGPlot::Labeller::_call_if_can('facet') // '') eq 'wrap') { } 0 2 2
Condition33%1/3
$labels->$Chart::GGPlot::Labeller::_call_if_can("facet") // ""
l!l
002
MC/DC0%0/1
$labels->$Chart::GGPlot::Labeller::_call_if_can("facet") // ""
$labels->$Chart::GGPlot::Labeller::_call_if_can("facet")
Truth table50%1/2
A
A= $labels->$Chart::GGPlot::Labeller::_call_if_can("facet")
Aresult
11
00
124 2 ▶ if ( defined $rows and defined $cols ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rows and defined $cols) 0 2 2
Condition0%0/3
defined $rows and defined $cols
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rows and defined $cols
defined $rows defined $cols
Truth table0%0/3
A and B
A= defined $rowsB= defined $cols
ABresult
0X0
100
111
125 2 die "Cannot supply both rows and cols to facet_wrap()";
126 }
127 2 ▶ return ( $cols // $rows );
Condition0%0/3
$cols // $rows
l!l&&r!l&&!r
000
MC/DC0%0/2
$cols // $rows
$cols $rows
Truth table0%0/3
A // B
A= $colsB= $rows
ABresult
1X1
011
000
128 }
129 else {
130 2 ▶ if ( ( $labels->$_call_if_can('type') // '' ) eq 'rows' )
Branch: 1 branch
BranchTrueFalseTotal
if (($labels->$Chart::GGPlot::Labeller::_call_if_can('type') // '') eq 'rows') { } 1 1 2
Condition0%0/2
$labels->$Chart::GGPlot::Labeller::_call_if_can("type") // ""
l!l
00
MC/DC0%0/1
$labels->$Chart::GGPlot::Labeller::_call_if_can("type") // ""
$labels->$Chart::GGPlot::Labeller::_call_if_can("type")
Truth table0%0/2
A
A= $labels->$Chart::GGPlot::Labeller::_call_if_can("type")
Aresult
11
00
131 {
132 2 return $rows;
133 }
134 else {
135 2 return $cols;
136 }
137 }
138 }
139  
140  
141 2 ▶classmethod labeller (:$_rows=undef, :$_cols=undef, :$_multi_line=true,
Subroutine labeller: called CC=6 SCAR=18.7
Pod documented
142 2 ▶ :$_default='value', %params) {
Branch: 4 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod labeller (expected 1, got ' . @_ . ')') 0 2 2
@_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for classmethod labeller") 0 2 2
exists $params{'_multi_line'} ? : 0 2 2
exists $params{'_default'} ? : 2 0 2
Condition33%1/3
@_ > 1 and (@_ - 1) % 2
!ll&&!rl&&r
020
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1 (@_ - 1) % 2
Truth table33%1/3
A and B
A= @_ > 1B= (@_ - 1) % 2
ABresult
0X0
100
111
143 1 $_default = $class->as_labeller( $_default, 'value', $_multi_line );
144  
145 1 ▶ my $f = fun( DataFrame $labels) {
Subroutine __ANON__: called CC=10 SCAR=23.6
146 1 ▶ my $margin_labeller =
Condition33%1/3
defined $_rows or defined $_cols
l!l&&r!l&&!r
400
MC/DC0%0/2
defined $_rows or defined $_cols
defined $_rows defined $_cols
Truth table33%1/3
A or B
A= defined $_rowsB= defined $_cols
ABresult
1X1
011
000
147 ( defined $_rows or defined $_cols )
148 ? $class->_resolve_labeller( $_rows, $_cols, $labels )
149 : undef;
150 1 if ( defined $margin_labeller ) {
151 1 return $class->as_labeller( $margin_labeller, $_default );
152 }
153 else {
154 4 ▶ my %labellers = pairmap { $a => $class->as_labeller($b) } %params;
Subroutine __ANON__: called CC=1 SCAR=0.0
155 my $ea = each_arrayref(
156 @{
157 $labels->names->map(
158 4 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
159 my $labeller = $labellers{$_} // $_default;
160 $labeller->( $labels->select_columns( [$_] ) );
161 }
162 )
163 }
164 );
165 my $rslt = [ 0 .. $labels->nrow - 1 ]->map(
166 8 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
167 my @row_data = $ea->();
168 [ map { @$_ } @row_data ];
169 }
170 );
171 return (
172 $_multi_line
173 ? $rslt
174 : $class->_collapse_labels_lines($rslt)
175 );
176 }
177 1 };
178 1 return $class->new( func => $f );
179 }
180  
181 __PACKAGE__->meta->make_immutable;
182  
183 1;
184  
185 __END__
« Chart/GGPlot/Layer.pm ↑ Summary Chart/GGPlot/Facet.pm »