Graph/Glyph/axis.pm

filter: Statementstmt 58.3% 56 / 96 Branchbran 41.6% 20 / 48 Conditioncond 40.0% 4 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 13 / 13 Podpod 90.9% 10 / 11 totaltotal 55.9% 103 / 184 CC 29 SCAR 40.6
CC
29
Cov
52%
draw
122.7
x_intercept
2.0
y_intercept
2.0
CRAP 57.9
« Graph/Glyph/heatmap.pm ↑ Summary Frame.pm »
1 package SVG::Graph::Glyph::axis;
2  
3 1 ▶use base SVG::Graph::Glyph;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head2 draw
7  
8 Title : draw
9 Usage :
10 Function:
11 Example :
12 Returns :
13 Args :
14  
15  
16 =cut
17  
18 4 ▶sub draw{
Subroutine draw: called CC=19 SCAR=48.1
Pod documented
19 4 my ($self,@args) = @_;
20  
21 4 my $id = 'n'.sprintf("%07d",int(rand(9999999)));
22 #my $frame_transform = $self->frame_transform;
23 4 my $group = $self->svg->group(id=>"axis$id");
24  
25 4 my $xscale = $self->xsize / $self->group->xrange;
26 4 my $yscale = $self->ysize / $self->group->yrange;
27  
28 4 ▶ my $xintercept = $self->x_intercept || 0;
Condition50%1/2
$self->x_intercept || 0
l!l
04
MC/DC0%0/1
$self->x_intercept || 0
$self->x_intercept
Truth table50%1/2
A
A= $self->x_intercept
Aresult
11
00
29 4 ▶ my $yintercept = $self->y_intercept || 0;
Condition50%1/2
$self->y_intercept || 0
l!l
04
MC/DC0%0/1
$self->y_intercept || 0
$self->y_intercept
Truth table50%1/2
A
A= $self->y_intercept
Aresult
11
00
30  
31 #draw x axis line
32 4 $group->line(x1=>$self->xoffset,
33 y1=>$self->yoffset + $self->ysize - ($yintercept * $yscale),
34 x2=>$self->xoffset + $self->xsize,
35 y2=>$self->yoffset + $self->ysize - ($yintercept * $yscale),
36 style=>{$self->_style}
37 );
38  
39 #draw y axis line
40 4 $group->line(x1=>$self->xoffset + ($xintercept * $xscale),
41 y1=>$self->yoffset,
42 x2=>$self->xoffset + ($xintercept * $xscale),
43 y2=>$self->yoffset + $self->ysize,
44 style=>{$self->_style}
45 );
46  
47 4 my @x_tick_labels = ();
48 4 my @x_intertick_labels = ();
49 4 ▶ if($self->x_tick_labels){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->x_tick_labels) 0 4 4
50 0 @x_tick_labels = @{ $self->x_tick_labels };
51 }
52 4 ▶ if($self->x_intertick_labels){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->x_intertick_labels) 0 4 4
53 0 @x_intertick_labels = @{ $self->x_intertick_labels };
54 }
55  
56 4 my @y_tick_labels = ();
57 4 my @y_intertick_labels = ();
58 4 ▶ if($self->y_tick_labels){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->y_tick_labels) 0 4 4
59 0 @y_tick_labels = @{ $self->y_tick_labels };
60 }
61 4 ▶ if($self->y_intertick_labels){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->y_intertick_labels) 0 4 4
62 0 @y_intertick_labels = @{ $self->y_intertick_labels };
63 }
64  
65 #x ticks
66 4 ▶ if($self->x_absolute_ticks and $self->x_fractional_ticks){
Branch: 3 branches
BranchTrueFalseTotal
if ($self->x_absolute_ticks and $self->x_fractional_ticks) { } 0 4 4
elsif ($self->x_absolute_ticks) { } 0 4 4
elsif ($self->x_fractional_ticks) { } 0 4 4
Condition33%1/3
$self->x_absolute_ticks and $self->x_fractional_ticks
!ll&&!rl&&r
400
MC/DC0%0/2
$self->x_absolute_ticks and $self->x_fractional_ticks
$self->x_absolute_ticks $self->x_fractional_ticks
Truth table33%1/3
A and B
A= $self->x_absolute_ticksB= $self->x_fractional_ticks
ABresult
0X0
100
111
67 0 die "x axis can't have both absolute and fractional ticks";
68 } elsif($self->x_absolute_ticks){
69  
70 0 ▶ for(my $tick = $self->group->xmin ; $tick <= $self->group->xmax; $tick += $self->x_absolute_ticks){
Branch: 1 branch
BranchTrueFalseTotal
if ($tick <= $self->group->xmax) 0 0 0
71 0 my $tickpos = ($tick - $self->group->xmin) * $xscale;
72  
73 0 $group->line(x1=>$self->xoffset+$tickpos,
74 y1=>$self->yoffset+$self->ysize - ($self->y_intercept * $yscale),
75 x2=>$self->xoffset+$tickpos,
76 y2=>$self->yoffset+$self->ysize - ($self->y_intercept * $yscale)+($self->group->_parent_svg->margin/8),
77 style=>{$self->_style}
78 );
79  
80  
81 #tick label
82 0 my $x_tick_label = shift @x_tick_labels;
83 0 my $x = $self->xoffset + $tickpos;
84 0 my $y = $self->yoffset+$self->ysize - ($self->y_intercept * $yscale)+($self->group->_parent_svg->margin/4);
85 0 $group->text(
86 x=>$x,
87 y=>$y,
88 transform=>"rotate(90,$x,$y)",
89 )->cdata($x_tick_label);
90  
91 #intertick label
92 0 my $x_intertick_label = shift @x_intertick_labels;
93 0 $tickpos = (((2 * $tick) - 1) / 2) * $xscale;
94 0 $x = $self->xoffset + $tickpos;
95 0 $group->text(
96 x=>$x,
97 y=>$y,
98 transform=>"rotate(90,$x,$y)",
99 )->cdata($x_intertick_label);
100  
101 }
102 } elsif($self->x_fractional_ticks){
103 0 my $inc = $self->group->xrange / $self->x_fractional_ticks;
104 0 ▶ for(my $tick = $self->group->xmin ; $tick <= $self->group->xmax; $tick += $inc){
Branch: 1 branch
BranchTrueFalseTotal
if ($tick <= $self->group->xmax) 0 0 0
105 0 my $tickpos = ($tick - $self->group->xmin) * $xscale;
106  
107 0 $group->line(x1=>$self->xoffset+$tickpos,
108 y1=>$self->yoffset+$self->ysize - ($self->y_intercept * $yscale),
109 x2=>$self->xoffset+$tickpos,
110 y2=>$self->yoffset+$self->ysize - ($self->y_intercept * $yscale)+($self->group->_parent_svg->margin/8),
111 style=>{$self->_style}
112 );
113  
114 }
115 }
116  
117 #y ticks
118 4 ▶ if($self->y_absolute_ticks and $self->y_fractional_ticks){
Branch: 3 branches
BranchTrueFalseTotal
if ($self->y_absolute_ticks and $self->y_fractional_ticks) { } 0 4 4
elsif ($self->y_absolute_ticks) { } 0 4 4
elsif ($self->y_fractional_ticks) { } 0 4 4
Condition33%1/3
$self->y_absolute_ticks and $self->y_fractional_ticks
!ll&&!rl&&r
400
MC/DC0%0/2
$self->y_absolute_ticks and $self->y_fractional_ticks
$self->y_absolute_ticks $self->y_fractional_ticks
Truth table33%1/3
A and B
A= $self->y_absolute_ticksB= $self->y_fractional_ticks
ABresult
0X0
100
111
119 0 die "y axis can't have both absolute and fractional ticks";
120 } elsif($self->y_absolute_ticks){
121 0 ▶ for(my $tick = $self->group->ymin ; $tick <= $self->group->ymax; $tick += $self->y_absolute_ticks){
Branch: 1 branch
BranchTrueFalseTotal
if ($tick <= $self->group->ymax) 0 0 0
122 0 my $tickpos = ($tick - $self->group->ymin) * $yscale;
123  
124 0 $group->line(x1=>$self->xoffset + ($self->x_intercept * $xscale),
125 y1=>$self->yoffset+$self->ysize-$tickpos,
126 x2=>$self->xoffset + ($self->x_intercept * $xscale)-($self->group->_parent_svg->margin/8),
127 y2=>$self->yoffset+$self->ysize-$tickpos,
128 style=>{$self->_style}
129 );
130  
131  
132 #tick label
133 0 my $y_tick_label = shift @y_tick_labels;
134 # my $x = $self->xoffset + $tickpos;
135 0 my $x = $self->xoffset + ($self->x_intercept * $xscale) - ($self->group->_parent_svg->margin);
136 # my $y = $self->yoffset+$self->ysize+($self->group->_parent_svg->margin/4);
137 0 my $y = $self->yoffset + $self->ysize - $tickpos;
138 0 $group->text(
139 x=>$x,
140 y=>$y,
141 # transform=>"rotate(90,$x,$y)",
142 )->cdata($y_tick_label);
143  
144 #intertick label
145 0 my $y_intertick_label = shift @y_intertick_labels;
146 0 $tickpos = (((2 * $tick) - 1) / 2) * $xscale;
147 0 $x = $self->xoffset + $tickpos;
148 0 $group->text(
149 x=>$x,
150 y=>$y,
151 # transform=>"rotate(90,$x,$y)",
152 )->cdata($y_intertick_label);
153  
154 }
155 } elsif($self->y_fractional_ticks){
156 0 my $inc = $self->group->yrange / $self->y_fractional_ticks;
157 0 ▶ for(my $tick = $self->group->ymin ; $tick <= $self->group->ymax ; $tick += $inc){
Branch: 1 branch
BranchTrueFalseTotal
if ($tick <= $self->group->ymax) 0 0 0
158 0 my $tickpos = ($tick - $self->group->ymin) * $xscale;
159  
160 0 $group->line(x1=>$self->xoffset + ($self->x_intercept * $xscale),
161 y1=>$self->yoffset+$self->ysize-$tickpos,
162 x2=>$self->xoffset + ($self->x_intercept * $xscale)-($self->group->_parent_svg->margin/8),
163 y2=>$self->yoffset+$self->ysize-$tickpos,
164 style=>{$self->_style}
165 );
166 }
167 }
168  
169 }
170  
171 =head2 x_intercept
172  
173 Title : x_intercept
174 Usage : $obj->x_intercept($newval)
175 Function:
176 Example :
177 Returns : value of x_intercept (a scalar)
178 Args : on set, new value (a scalar or undef, optional)
179  
180  
181 =cut
182  
183 4 ▶sub x_intercept{
Subroutine x_intercept: called CC=2 SCAR=7.1
Pod documented
184 4 my $self = shift;
185  
186 4 ▶ return $self->{'x_intercept'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
187 4 return $self->{'x_intercept'};
188 }
189  
190 =head2 y_intercept
191  
192 Title : y_intercept
193 Usage : $obj->y_intercept($newval)
194 Function:
195 Example :
196 Returns : value of y_intercept (a scalar)
197 Args : on set, new value (a scalar or undef, optional)
198  
199  
200 =cut
201  
202 4 ▶sub y_intercept{
Subroutine y_intercept: called CC=2 SCAR=7.1
Pod documented
203 4 my $self = shift;
204  
205 4 ▶ return $self->{'y_intercept'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
206 4 return $self->{'y_intercept'};
207 }
208  
209 =head2 x_fractional_ticks
210  
211 Title : x_fractional_ticks
212 Usage : $obj->x_fractional_ticks($newval)
213 Function:
214 Example :
215 Returns : value of x_fractional_ticks (a scalar)
216 Args : on set, new value (a scalar or undef, optional)
217  
218  
219 =cut
220  
221 4 ▶sub x_fractional_ticks{
Subroutine x_fractional_ticks: called CC=2 SCAR=7.1
Pod documented
222 4 my $self = shift;
223  
224 4 ▶ return $self->{'x_fractional_ticks'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
225 4 return $self->{'x_fractional_ticks'};
226 }
227  
228 =head2 y_fractional_ticks
229  
230 Title : y_fractional_ticks
231 Usage : $obj->y_fractional_ticks($newval)
232 Function:
233 Example :
234 Returns : value of y_fractional_ticks (a scalar)
235 Args : on set, new value (a scalar or undef, optional)
236  
237  
238 =cut
239  
240 4 ▶sub y_fractional_ticks{
Subroutine y_fractional_ticks: called CC=2 SCAR=7.1
Pod documented
241 4 my $self = shift;
242  
243 4 ▶ return $self->{'y_fractional_ticks'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
244 4 return $self->{'y_fractional_ticks'};
245 }
246  
247 =head2 x_absolute_ticks
248  
249 Title : x_absolute_ticks
250 Usage : $obj->x_absolute_ticks($newval)
251 Function:
252 Example :
253 Returns : value of x_absolute_ticks (a scalar)
254 Args : on set, new value (a scalar or undef, optional)
255  
256  
257 =cut
258  
259 8 ▶sub x_absolute_ticks{
Subroutine x_absolute_ticks: called CC=2 SCAR=7.1
Pod documented
260 8 my $self = shift;
261  
262 8 ▶ return $self->{'x_absolute_ticks'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 8 8
263 8 return $self->{'x_absolute_ticks'};
264 }
265  
266 =head2 y_fractional_ticks
267  
268 Title : y_fractional_ticks
269 Usage : $obj->y_fractional_ticks($newval)
270 Function:
271 Example :
272 Returns : value of y_fractional_ticks (a scalar)
273 Args : on set, new value (a scalar or undef, optional)
274  
275  
276 =cut
277  
278 8 ▶sub y_absolute_ticks{
Subroutine y_absolute_ticks: called CC=2 SCAR=7.1
Pod undocumented
279 8 my $self = shift;
280  
281 8 ▶ return $self->{'y_absolute_ticks'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 8 8
282 8 return $self->{'y_absolute_ticks'};
283 }
284  
285 =head2 x_intertick_labels
286  
287 Title : x_intertick_labels
288 Usage : $obj->x_intertick_labels($newval)
289 Function:
290 Example :
291 Returns : value of x_intertick_labels (a scalar)
292 Args : on set, new value (a scalar or undef, optional)
293  
294  
295 =cut
296  
297 4 ▶sub x_intertick_labels{
Subroutine x_intertick_labels: called CC=2 SCAR=7.1
Pod documented
298 4 my $self = shift;
299  
300 4 ▶ return $self->{'x_intertick_labels'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
301 4 return $self->{'x_intertick_labels'};
302 }
303  
304 =head2 x_tick_labels
305  
306 Title : x_tick_labels
307 Usage : $obj->x_tick_labels($newval)
308 Function:
309 Example :
310 Returns : value of x_tick_labels (a scalar)
311 Args : on set, new value (a scalar or undef, optional)
312  
313  
314 =cut
315  
316 4 ▶sub x_tick_labels{
Subroutine x_tick_labels: called CC=2 SCAR=7.1
Pod documented
317 4 my $self = shift;
318  
319 4 ▶ return $self->{'x_tick_labels'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
320 4 return $self->{'x_tick_labels'};
321 }
322  
323 =head2 y_intertick_labels
324  
325 Title : y_intertick_labels
326 Usage : $obj->y_intertick_labels($newval)
327 Function:
328 Example :
329 Returns : value of y_intertick_labels (a scalar)
330 Args : on set, new value (a scalar or undef, optional)
331  
332  
333 =cut
334  
335 4 ▶sub y_intertick_labels{
Subroutine y_intertick_labels: called CC=2 SCAR=7.1
Pod documented
336 4 my $self = shift;
337  
338 4 ▶ return $self->{'y_intertick_labels'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
339 4 return $self->{'y_intertick_labels'};
340 }
341  
342 =head2 y_tick_labels
343  
344 Title : y_tick_labels
345 Usage : $obj->y_tick_labels($newval)
346 Function:
347 Example :
348 Returns : value of y_tick_labels (a scalar)
349 Args : on set, new value (a scalar or undef, optional)
350  
351  
352 =cut
353  
354 4 ▶sub y_tick_labels{
Subroutine y_tick_labels: called CC=2 SCAR=7.1
Pod documented
355 4 my $self = shift;
356  
357 4 ▶ return $self->{'y_tick_labels'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
358 4 return $self->{'y_tick_labels'};
359 }
360  
361 1 1;
« Graph/Glyph/heatmap.pm ↑ Summary Frame.pm »