line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Graph::DataSet; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
38773
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
262
|
|
4
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
4808
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new |
9
|
|
|
|
|
|
|
{ |
10
|
49
|
|
|
49
|
1
|
11523
|
my $class = shift; |
11
|
|
|
|
|
|
|
my $obj = { |
12
|
|
|
|
|
|
|
values => [], |
13
|
|
|
|
|
|
|
labels => undef, |
14
|
|
|
|
|
|
|
hash => undef, |
15
|
1
|
|
|
1
|
|
8
|
sort => sub { sort @_ } |
16
|
49
|
|
|
|
|
287
|
}; |
17
|
|
|
|
|
|
|
|
18
|
49
|
100
|
|
|
|
148
|
if( @_ ) |
19
|
|
|
|
|
|
|
{ |
20
|
48
|
100
|
|
|
|
138
|
if( 'ARRAY' eq ref $_[0] ) |
|
|
100
|
|
|
|
|
|
21
|
|
|
|
|
|
|
{ |
22
|
42
|
|
|
|
|
81
|
$obj->{values} = shift; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif( 'HASH' eq ref $_[0] ) |
25
|
|
|
|
|
|
|
{ |
26
|
4
|
|
|
|
|
9
|
$obj->{hash} = shift; |
27
|
|
|
|
|
|
|
} |
28
|
48
|
100
|
|
|
|
154
|
$obj->{labels} = shift if 'ARRAY' eq ref $_[0]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
49
|
100
|
|
|
|
122
|
if( @_ ) |
32
|
|
|
|
|
|
|
{ |
33
|
5
|
100
|
|
|
|
20
|
die "Odd number of parameters to new.\n" unless 0 == ( @_ % 2 ); |
34
|
4
|
|
|
|
|
6
|
$obj = { %{$obj}, @_ }; |
|
4
|
|
|
|
|
19
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
48
|
|
|
|
|
120
|
$obj = bless $obj, $class; |
38
|
|
|
|
|
|
|
|
39
|
48
|
|
|
|
|
147
|
$obj->_initialize(); |
40
|
|
|
|
|
|
|
|
41
|
48
|
|
|
|
|
149
|
return $obj; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_values |
45
|
|
|
|
|
|
|
{ |
46
|
54
|
|
|
54
|
1
|
3295
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
54
|
100
|
|
|
|
125
|
return wantarray ? @{ $self->{values} } : $self->{values}; |
|
44
|
|
|
|
|
187
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_labels |
52
|
|
|
|
|
|
|
{ |
53
|
95
|
|
|
95
|
1
|
5780
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
95
|
100
|
|
|
|
178
|
return wantarray ? @{ $self->{labels} } : $self->{labels}; |
|
85
|
|
|
|
|
564
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _initialize |
59
|
|
|
|
|
|
|
{ |
60
|
48
|
|
|
48
|
|
66
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
48
|
100
|
|
|
|
186
|
if( defined $self->{hash} ) |
|
|
100
|
|
|
|
|
|
63
|
|
|
|
|
|
|
{ |
64
|
5
|
100
|
|
|
|
20
|
unless( defined $self->{labels} ) |
65
|
|
|
|
|
|
|
{ |
66
|
4
|
100
|
|
|
|
10
|
if( defined $self->{sort} ) |
67
|
|
|
|
|
|
|
{ |
68
|
3
|
|
|
|
|
4
|
$self->{labels} = [ $self->{sort}->( keys %{ $self->{hash} } ) ]; |
|
3
|
|
|
|
|
13
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else |
71
|
|
|
|
|
|
|
{ |
72
|
1
|
|
|
|
|
2
|
$self->{labels} = [ keys %{ $self->{hash} } ]; |
|
1
|
|
|
|
|
6
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
5
|
|
|
|
|
27
|
$self->{values} = [ @{ $self->{hash} }{ @{ $self->{labels} } } ]; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
9
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif( !defined $self->{labels} ) |
79
|
|
|
|
|
|
|
{ |
80
|
6
|
|
|
|
|
10
|
$self->{labels} = [ ( '' ) x scalar( @{ $self->{values} } ) ]; |
|
6
|
|
|
|
|
24
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
48
|
100
|
|
|
|
60
|
if( scalar @{ $self->{values} } > scalar @{ $self->{labels} } ) |
|
48
|
|
|
|
|
79
|
|
|
48
|
|
|
|
|
120
|
|
84
|
|
|
|
|
|
|
{ |
85
|
1
|
|
|
|
|
3
|
push @{ $self->{labels} }, |
|
1
|
|
|
|
|
2
|
|
86
|
1
|
|
|
|
|
2
|
( '' ) x ( scalar @{ $self->{values} } - scalar @{ $self->{labels} } ); |
|
1
|
|
|
|
|
4
|
|
87
|
|
|
|
|
|
|
} |
88
|
48
|
|
|
|
|
80
|
return; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
__END__ |