line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Google::Chart::Encoding::Extended; |
3
|
1
|
|
|
1
|
|
4999
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Scalar::Util qw(looks_like_number); |
5
|
|
|
|
|
|
|
use namespace::clean -except => qw(meta); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Google::Chart::Encoding'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'max_value' => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => 'Num', |
12
|
|
|
|
|
|
|
required => 1, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'min_value' => ( |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
isa => 'Num', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
default => 0, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @map = ('A'..'Z', 'a'..'z', 0..9, '-', '.'); |
23
|
|
|
|
|
|
|
my $map_size = scalar @map; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub encode { |
26
|
|
|
|
|
|
|
my ($self, $sets) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $max = $self->max_value; |
29
|
|
|
|
|
|
|
my $min = $self->min_value; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $scale = $map_size ** 2 - 1; |
32
|
|
|
|
|
|
|
my $result = 'e:' . join(',', map { |
33
|
|
|
|
|
|
|
my $set = $_; |
34
|
|
|
|
|
|
|
join( '', |
35
|
|
|
|
|
|
|
map { |
36
|
|
|
|
|
|
|
my $data = $_; |
37
|
|
|
|
|
|
|
my $v = '__'; |
38
|
|
|
|
|
|
|
# if (defined $data && looks_like_number($data)) { |
39
|
|
|
|
|
|
|
my $normalized = int((($data - $min) * $scale) / abs($max - $min)); |
40
|
|
|
|
|
|
|
if ($normalized < 0) { |
41
|
|
|
|
|
|
|
$normalized = 0; |
42
|
|
|
|
|
|
|
} elsif ($normalized >= $scale) { |
43
|
|
|
|
|
|
|
$normalized = $scale - 1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$v = $map[ int($normalized / $map_size) ] . $map[ int($normalized % $map_size) ]; |
47
|
|
|
|
|
|
|
# } |
48
|
|
|
|
|
|
|
$v; |
49
|
|
|
|
|
|
|
} @{$set->data} |
50
|
|
|
|
|
|
|
) |
51
|
|
|
|
|
|
|
} @$sets |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
return $result; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Google::Chart::Encoding::Extended - Google::Chart Extended Encoding |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 parameter_value |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |