File Coverage

blib/lib/SVG/Graph/Glyph/line.pm
Criterion Covered Total %
statement 23 23 100.0
branch 1 2 50.0
condition 2 3 66.6
subroutine 3 3 100.0
pod 1 1 100.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package SVG::Graph::Glyph::line;
2              
3 1     1   7 use base SVG::Graph::Glyph;
  1         1  
  1         654  
4 1     1   7 use strict;
  1         2  
  1         367  
5              
6             =head2 draw
7              
8             Title : draw
9             Usage :
10             Function:
11             Example :
12             Returns :
13             Args :
14              
15              
16             =cut
17              
18             sub draw{
19 1     1 1 2 my ($self,@args) = @_;
20              
21 1         4 my $id = 'n'.sprintf("%07d",int(rand(9999999)));
22 1         4 my $group = $self->svg->group(id=>"line$id");
23              
24 1         58 my $xscale = $self->xsize / $self->group->xrange;
25 1         10 my $yscale = $self->ysize / $self->group->yrange;
26              
27 1         6 my($x1,$x2,$y1,$y2);
28 1         4 foreach my $datum (sort {$a->x <=> $b->x} $self->group->data){
  64         164  
29 20 50 66     50 if(!defined($x1) and !defined($y1)){
30 1         3 $x1 = (($datum->x - $self->group->xmin) * $xscale) + $self->xoffset;
31 1         4 $y1 = ($self->ysize - ($datum->y - $self->group->ymin) * $yscale) + $self->yoffset;
32 1         3 next;
33             }
34              
35 19         54 $x2 = (($datum->x - $self->group->xmin) * $xscale) + $self->xoffset;
36 19         52 $y2 = ($self->ysize - ($datum->y - $self->group->ymin) * $yscale) + $self->yoffset;
37              
38 19         65 $group->line(x1=>$x1,y1=>$y1,x2=>$x2,y2=>$y2,style=>{$self->_style});
39              
40 19         1245 $x1 = $x2;
41 19         41 $y1 = $y2;
42             }
43             }
44              
45             1;