Chart/GGPlot/Theme/ElementTree.pm

filter: Statementstmt 84.6% 55 / 65 Branchbran 55.0% 11 / 20 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 86.6% 13 / 15 Podpod 100% 3 / 3 totaltotal 73.4% 83 / 113 CC 14 SCAR 18.0
CC
14
Cov
74%
__ANON__
20.0
el_def
7.8
default_element_tree
4.3
CRAP 6.0
« Chart/GGPlot/Util/_Base.pm ↑ Summary Chart/GGPlot/Limits.pm »
1 package Chart::GGPlot::Theme::ElementTree;
2  
3 # ABSTRACT: Definitions of theme elements
4  
5 3 ▶use Chart::GGPlot::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Function::Parameters qw(classmethod);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our $VERSION = '0.002003'; # VERSION
10  
11 3 ▶use parent qw(Chart::GGPlot::Params);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Types::Standard qw(Any ArrayRef Enum HashRef InstanceOf Num Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use Chart::GGPlot::Theme::Defaults qw(theme_grey);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use Chart::GGPlot::Theme::Element::Functions qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Chart::GGPlot::Theme::ElementTree;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # Overrides Chart::GGPlot::Params behavior to support both "foo.bar" and
20 # "foo_bar" as element name.
21 638 ▶classmethod transform_key ($key) {
Subroutine transform_key: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for classmethod transform_key (expected 2, got ' . @_ . ')') 0 638 638
@_ > 2 and Function::Parameters::_croak('Too many arguments for classmethod transform_key (expected 2, got ' . @_ . ')') 0 638 638
22 638 return ( $key =~ s/\./_/gr );
23 3 }
24  
25  
26 70 ▶classmethod el_def ( $type, $inherit = [], $desc = '' ) {
Subroutine el_def: called CC=7 SCAR=20.5
Pod documented
Branch: 4 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for classmethod el_def (expected 2, got ' . @_ . ')') 0 70 70
@_ > 4 and Function::Parameters::_croak('Too many arguments for classmethod el_def (expected 4, got ' . @_ . ')') 0 70 70
@_ < 3 and do { @_ < 2 and $inherit = []; $desc = "" } 70 0 70
@_ < 2 and $inherit = [] 14 56 70
27 70 ▶ $inherit = Ref::Util::is_arrayref($inherit) ? $inherit : [ $inherit // () ];
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_arrayref($inherit) ? : 14 56 70
Condition33%1/3
$inherit // ()
l!l&&r!l&&!r
5600
MC/DC0%0/2
$inherit // ()
$inherit ()
Truth table33%1/3
A // B
A= $inheritB= ()
ABresult
1X1
011
000
28 return {
29 70 type => $type,
30 inherit => $inherit,
31 description => $desc,
32 };
33 3 }
34  
35  
36 1 ▶classmethod default_element_tree () {
Subroutine default_element_tree: called CC=3 SCAR=14.7
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod default_element_tree (expected 1, got ' . @_ . ')') 0 1 1
@_ > 1 and Function::Parameters::_croak('Too many arguments for classmethod default_element_tree (expected 1, got ' . @_ . ')') 0 1 1
37 1 my $ElementLine = InstanceOf ["Chart::GGPlot::Theme::Element::Line"];
38 1 my $ElementRect = InstanceOf ["Chart::GGPlot::Theme::Element::Rect"];
39 1 my $ElementText = InstanceOf ["Chart::GGPlot::Theme::Element::Text"];
40  
41 #my $Margin = InstanceOf ["Chart::GGPlot::Margin"];
42  
43 my $Character =
44 1 ▶ ( ArrayRef [ ( Str | Num ) ] )->plus_coercions( Any, sub { [ $_, $_ ] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
45  
46 my $TagPosition = (
47 (
48 Enum [
49 qw(
50 topleft top topright
51 left right bottomleft
52 bottom bottomright
53 )
54 ]
55 0 ▶ ) | ( ArrayRef [Num] )->where( sub { @$_ == 2 } )
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 )->plus_coercions(
57 Str,
58 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
59 0 state $mapping;
60 0 ▶ unless ($mapping) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mapping) 0 0 0
61 0 $mapping = {};
62 0 my @setup = (
63 [qw(bottom left)], [qw(top left)],
64 [qw(bottom right)], [qw(top right)],
65 );
66 0 for my $item (@setup) {
67 0 my ( $a, $b ) = @$item;
68 0 my $just = "$a$b";
69 $mapping->{"$b$a"} =
70 0 $mapping->{"${a}_$b"} = $mapping->{"${b}_$a"} = $just;
71 }
72 }
73 0 ▶ return ( $mapping->{$_} // $_ );
Condition0%0/3
$mapping->{$_} // $_
l!l&&r!l&&!r
000
MC/DC0%0/2
$mapping->{$_} // $_
$mapping->{$_} $_
Truth table0%0/3
A // B
A= $mapping->{$_}B= $_
ABresult
1X1
011
000
74 }
75 1 );
76  
77 # this is just to have something shorter than $class->el_def
78 1 ▶ my $el_def = sub { $class->el_def(@_); };
Subroutine __ANON__: called CC=1 SCAR=0.0
79  
80 1 return $class->new(
81 line => &$el_def($ElementLine),
82 rect => &$el_def($ElementRect),
83 text => &$el_def($ElementText),
84 title => &$el_def( $ElementText, "text" ),
85 axis_line => &$el_def( $ElementLine, "line" ),
86 axis_text => &$el_def( $ElementText, "text" ),
87 axis_title => &$el_def( $ElementText, "title" ),
88 axis_ticks => &$el_def( $ElementLine, "line" ),
89  
90 # legend_key_size => &$el_def($Unit),
91 panel_grid => &$el_def( $ElementLine, "line" ),
92 panel_grid_major => &$el_def( $ElementLine, "panel_grid" ),
93 panel_grid_minor => &$el_def( $ElementLine, "panel_grid" ),
94 strip_text => &$el_def( $ElementText, "text" ),
95  
96 axis_line_x => &$el_def( $ElementLine, "axis_line" ),
97 axis_line_x_top => &$el_def( $ElementLine, "axis_line_x" ),
98 axis_line_x_bottom => &$el_def( $ElementLine, "axis_line_x" ),
99 axis_line_y => &$el_def( $ElementLine, "axis_line" ),
100 axis_line_y_left => &$el_def( $ElementLine, "axis_line_y" ),
101 axis_line_y_right => &$el_def( $ElementLine, "axis_line_y" ),
102 axis_text_x => &$el_def( $ElementText, "axis_text" ),
103 axis_text_x_top => &$el_def( $ElementText, "axis_text_x" ),
104 axis_text_x_bottom => &$el_def( $ElementText, "axis_text_x" ),
105 axis_text_y => &$el_def( $ElementText, "axis_text" ),
106 axis_text_y_left => &$el_def( $ElementText, "axis_text_y" ),
107 axis_text_y_right => &$el_def( $ElementText, "axis_text_y" ),
108  
109 # axis_ticks_length => &$el_def($Unit),
110 axis_ticks_x => &$el_def( $ElementLine, "axis_ticks" ),
111 axis_ticks_x_top => &$el_def( $ElementLine, "axis_ticks_x" ),
112 axis_ticks_x_bottom => &$el_def( $ElementLine, "axis_ticks_x" ),
113 axis_ticks_y => &$el_def( $ElementLine, "axis_ticks" ),
114 axis_ticks_y_left => &$el_def( $ElementLine, "axis_ticks_y" ),
115 axis_ticks_y_right => &$el_def( $ElementLine, "axis_ticks_y" ),
116 axis_title_x => &$el_def( $ElementText, "axis_title" ),
117 axis_title_x_top => &$el_def( $ElementText, "axis_title_x" ),
118 axis_title_x_bottom => &$el_def( $ElementText, "axis_title_x" ),
119 axis_title_y => &$el_def( $ElementText, "axis_title" ),
120 axis_title_y_left => &$el_def( $ElementText, "axis_title_y" ),
121 axis_title_y_right => &$el_def( $ElementText, "axis_title_y" ),
122  
123 legend_background => &$el_def( $ElementRect, "rect" ),
124  
125 # legend_margin => &$el_def($Margin),
126  
127 # legend_spacing => &$el_def($Unit),
128 # legend_spacing_x => &$el_def( $Unit, "legend_spacing" ),
129 # legend_spacing_y => &$el_def( $Unit, "legend_spacing" ),
130 legend_key => &$el_def( $ElementRect, "rect" ),
131  
132 # legend_key_height => &$el_def( $Unit, "legend_key_size" ),
133 # legend_key_width => &$el_def( $Unit, "legend_key_size" ),
134 legend_text => &$el_def( $ElementText, "text" ),
135 legend_text_align => &$el_def($Character),
136 legend_title => &$el_def( $ElementText, "title" ),
137 legend_title_align => &$el_def($Character),
138 legend_position => &$el_def($Character), # Need to also accept numbers
139 legend_direction => &$el_def($Character),
140 legend_justification => &$el_def($Character),
141 legend_box => &$el_def($Character),
142 legend_box_just => &$el_def($Character),
143  
144 # legend_box_margin => &$el_def($Margin),
145 legend_box_background => &$el_def( $ElementRect, "rect" ),
146  
147 # legend_box_spacing => &$el_def($Unit),
148  
149 panel_background => &$el_def( $ElementRect, "rect" ),
150 panel_border => &$el_def( $ElementRect, "rect" ),
151  
152 # panel_spacing => &$el_def($Unit),
153 # panel_spacing_x => &$el_def( $Unit, "panel_spacing" ),
154 # panel_spacing_y => &$el_def( $Unit, "panel_spacing" ),
155 panel_grid_major_x => &$el_def( $ElementLine, "panel_grid_major" ),
156 panel_grid_major_y => &$el_def( $ElementLine, "panel_grid_major" ),
157 panel_grid_minor_x => &$el_def( $ElementLine, "panel_grid_minor" ),
158 panel_grid_minor_y => &$el_def( $ElementLine, "panel_grid_minor" ),
159 panel_ontop => &$el_def(Any),
160  
161 strip_background => &$el_def( $ElementRect, "rect" ),
162 strip_background_x => &$el_def( $ElementRect, "strip_background" ),
163 strip_background_y => &$el_def( $ElementRect, "strip_background" ),
164 strip_text_x => &$el_def( $ElementText, "strip_text" ),
165 strip_text_y => &$el_def( $ElementText, "strip_text" ),
166 strip_placement => &$el_def($Character),
167 strip_placement_x => &$el_def( $Character, "strip_placement" ),
168 strip_placement_y => &$el_def( $Character, "strip_placement" ),
169  
170 # strip_switch_pad_grid => &$el_def($Unit),
171 # strip_switch_pad_wrap => &$el_def($Unit),
172  
173 plot_background => &$el_def( $ElementRect, "rect" ),
174 plot_title => &$el_def( $ElementText, "title" ),
175 plot_subtitle => &$el_def( $ElementText, "title" ),
176 plot_caption => &$el_def( $ElementText, "title" ),
177 plot_tag => &$el_def( $ElementText, "title" ),
178 plot_tag_position => &$el_def($TagPosition),
179  
180 # plot_margin => &$el_def($Margin),
181  
182 aspect_ratio => &$el_def($Character),
183 );
184 3 }
185  
186 3 1;
187  
188 __END__
« Chart/GGPlot/Util/_Base.pm ↑ Summary Chart/GGPlot/Limits.pm »