line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Data::DataSet; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Data::DataSet::VERSION = '2.88'; |
3
|
8
|
|
|
8
|
|
30975
|
use Moose; |
|
8
|
|
|
|
|
554295
|
|
|
8
|
|
|
|
|
72
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: A collection of series |
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
56064
|
use Chart::Clicker::Data::Range; |
|
8
|
|
|
|
|
48
|
|
|
8
|
|
|
|
|
6144
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'context' => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
default => sub { 'default'} |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'domain' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Chart::Clicker::Data::Range', |
20
|
|
|
|
|
|
|
default => sub { Chart::Clicker::Data::Range->new } |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'max_key_count' => ( is => 'rw', isa => 'Int', default => 0 ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'range' => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => 'Chart::Clicker::Data::Range', |
30
|
|
|
|
|
|
|
default => sub { Chart::Clicker::Data::Range->new } |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'series' => ( |
35
|
|
|
|
|
|
|
traits => [ 'Array' ], |
36
|
|
|
|
|
|
|
is => 'rw', |
37
|
|
|
|
|
|
|
isa => 'ArrayRef', |
38
|
|
|
|
|
|
|
default => sub { [] }, |
39
|
|
|
|
|
|
|
handles => { |
40
|
|
|
|
|
|
|
'count' => 'count', |
41
|
|
|
|
|
|
|
'add_to_series' => 'push', |
42
|
|
|
|
|
|
|
'get_series' => 'get' |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_all_series_keys { |
48
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
my %keys; |
51
|
0
|
|
|
|
|
0
|
for my $series (@{$self->series}) { |
|
0
|
|
|
|
|
0
|
|
52
|
0
|
|
|
|
|
0
|
foreach (@{$series->keys}) { $keys{$_} = 1}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
0
|
return keys %keys; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub get_series_keys { |
59
|
1
|
|
|
1
|
1
|
3
|
my ($self, $position) = @_; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
3
|
return map({ $_->keys->[$position] } @{ $self->series }); |
|
2
|
|
|
|
|
73
|
|
|
1
|
|
|
|
|
43
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_series_values { |
66
|
5
|
|
|
5
|
1
|
361
|
my ($self, $position) = @_; |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
|
|
8
|
return [ map({ $_->values->[$position] } @{ $self->series }) ]; |
|
10
|
|
|
|
|
399
|
|
|
5
|
|
|
|
|
376
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_series_values_for_key { |
73
|
2
|
|
|
2
|
1
|
12
|
my ($self, $key) = @_; |
74
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
3
|
return [ map({ $_->get_value_for_key($key) } @{ $self->series }) ]; |
|
4
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
84
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub largest_value_slice { |
80
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Prime out big variable with the value of the first slice |
83
|
1
|
|
|
|
|
3
|
my $big; |
84
|
1
|
|
|
|
|
2
|
foreach (@{ $self->get_series_values(0) }) { $big += $_; } |
|
1
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Check that value against all the remaining slices |
87
|
1
|
|
|
|
|
43
|
for my $i (0 .. $self->max_key_count - 1) { |
88
|
3
|
|
|
|
|
5
|
my $t; |
89
|
3
|
50
|
|
|
|
5
|
foreach (@{ $self->get_series_values($i) }) { $t += $_ if defined($_); } |
|
3
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
20
|
|
90
|
3
|
100
|
66
|
|
|
22
|
$big = $t if(($t > $big) || !defined($big)); |
91
|
|
|
|
|
|
|
} |
92
|
1
|
|
|
|
|
9
|
return $big; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub prepare { |
96
|
2
|
|
|
2
|
0
|
11
|
my ($self) = @_; |
97
|
|
|
|
|
|
|
|
98
|
2
|
100
|
66
|
|
|
110
|
unless($self->count && $self->count > 0) { |
99
|
1
|
|
|
|
|
11
|
die('Dataset has no series.'); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
2
|
my $stotal; |
103
|
1
|
|
|
|
|
4
|
foreach my $series (@{ $self->series }) { |
|
1
|
|
|
|
|
43
|
|
104
|
2
|
|
|
|
|
8
|
$series->prepare; |
105
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
88
|
$self->range->combine($series->range); |
107
|
|
|
|
|
|
|
|
108
|
2
|
|
|
|
|
3
|
my @keys = @{ $series->keys }; |
|
2
|
|
|
|
|
94
|
|
109
|
|
|
|
|
|
|
|
110
|
2
|
|
|
|
|
100
|
$self->domain->combine( |
111
|
|
|
|
|
|
|
Chart::Clicker::Data::Range->new({ |
112
|
|
|
|
|
|
|
lower => $keys[0], upper => $keys[ $#keys ] |
113
|
|
|
|
|
|
|
}) |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
2
|
100
|
|
|
|
93
|
if($series->key_count > $self->max_key_count) { |
117
|
1
|
|
|
|
|
48
|
$self->max_key_count($series->key_count); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
5
|
return 1; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
125
|
|
|
|
|
|
|
|
126
|
8
|
|
|
8
|
|
58
|
no Moose; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
63
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=pod |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 NAME |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Chart::Clicker::Data::DataSet - A collection of series |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 VERSION |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
version 2.88 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SYNOPSIS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
use Chart::Clicker::Data::DataSet; |
145
|
|
|
|
|
|
|
use Chart::Clicker::Data::Series; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my @vals = (12, 19, 90, 4, 44, 3, 78, 87, 19, 5); |
148
|
|
|
|
|
|
|
my @keys = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
149
|
|
|
|
|
|
|
my $series = Chart::Clicker::Data::Series->new({ |
150
|
|
|
|
|
|
|
keys => \@keys, |
151
|
|
|
|
|
|
|
values => \@vals |
152
|
|
|
|
|
|
|
}); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $ds = Chart::Clicker::Data::DataSet->new({ |
155
|
|
|
|
|
|
|
series => [ $series ] |
156
|
|
|
|
|
|
|
}); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 DESCRIPTION |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Chart::Clicker::Data::DataSet is a set of Series that are grouped for some |
161
|
|
|
|
|
|
|
logical reason or another. DatasSets can be associated with Renderers in the |
162
|
|
|
|
|
|
|
Chart. Unless you are doing something fancy like that you have no reason to |
163
|
|
|
|
|
|
|
use more than one in your chart. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 max_key_count |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Get the number of keys in the longest series. This will be set automatically. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 context |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Set/Get the context this DataSet will be charted under. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 domain |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Get the L<Range|Chart::Clicker::Data::Range> for the domain values |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 range |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Get the L<Range|Chart::Clicker::Data::Range> for the... range values... |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 series |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Set/Get the series for this DataSet |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 METHODS |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 add_to_series |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Add a series to this dataset. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head2 count |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Get the number of series in this dataset. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 get_series ($index) |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Get the series at the specified index. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 get_all_series_keys |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Returns an array of keys representing the union of all keys from all DataSets. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 get_series_keys |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Returns the key at the specified position for every series in this DataSet. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 get_series_values |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Returns the value at the specified position for every series in this DataSet |
212
|
|
|
|
|
|
|
as an ArrayRef. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 get_series_values_for_key |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Returns the value for the specified key for every series in this DataSet as an |
217
|
|
|
|
|
|
|
ArrayRef. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 largest_value_slice |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Finds the largest cumulative 'slice' in this dataset. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 AUTHOR |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Cold Hard Code, LLC. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
232
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |