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