line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Google::Chart::Data::Extended; |
4
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
7446
|
use Scalar::Util qw(looks_like_number); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
130
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Google::Chart::Data'; |
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
|
|
|
|
|
|
|
has '+dataset' => ( |
23
|
|
|
|
|
|
|
isa => 'ArrayRef[Google::Chart::Data::Extended::DataSet]', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
6
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub BUILDARGS { |
31
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# A dataset must be an array of arrays or array of values |
34
|
0
|
|
|
|
|
|
my @dataset; |
35
|
|
|
|
|
|
|
my @dataargs; |
36
|
0
|
|
|
|
|
|
my %args; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
0
|
|
|
|
if (@_ == 1 && ref $_[0] eq 'ARRAY') { |
39
|
0
|
|
|
|
|
|
@dataargs = @{$_[0]}; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
|
%args = @_; |
42
|
0
|
0
|
|
|
|
|
@dataargs = @{ delete $args{dataset} || [] }; |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if (! ref $dataargs[0] ) { |
46
|
0
|
|
|
|
|
|
@dataargs = ([ @dataargs]); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
foreach my $dataset ( @dataargs ) { |
50
|
0
|
0
|
|
|
|
|
if (! Scalar::Util::blessed $dataset) { |
51
|
0
|
|
|
|
|
|
$dataset = Google::Chart::Data::Extended::DataSet->new(data => $dataset) |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
push @dataset, $dataset; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return { %args, dataset => \@dataset } |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub parameter_value { |
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my $max = $self->max_value; |
62
|
0
|
|
|
|
|
|
my $min = $self->min_value; |
63
|
0
|
|
|
|
|
|
sprintf('e:%s', |
64
|
0
|
|
|
|
|
|
join( ',', map { $_->as_string({max => $max, min => $min}) } @{ $self->dataset } ) ); |
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package # hide from PAUSE |
68
|
|
|
|
|
|
|
Google::Chart::Data::Extended::DataSet; |
69
|
1
|
|
|
1
|
|
513
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
70
|
1
|
|
|
1
|
|
6852
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
subtype 'Google::Chart::Data::Extended::DataSet::Value' |
73
|
|
|
|
|
|
|
=> as 'Num'; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has 'data' => ( |
76
|
|
|
|
|
|
|
is => 'rw', |
77
|
|
|
|
|
|
|
isa => 'ArrayRef[Maybe[Google::Chart::Data::Extended::DataSet::Value]]', |
78
|
|
|
|
|
|
|
required => 1, |
79
|
|
|
|
|
|
|
default => sub { +[] }, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
1
|
|
2109
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
85
|
1
|
|
|
1
|
|
196
|
no Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my @map = ('A'..'Z', 'a'..'z', 0..9, '-', '.'); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub as_string { |
90
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
91
|
0
|
|
|
|
|
|
my $max = $args->{max}; |
92
|
0
|
|
|
|
|
|
my $min = $args->{min}; |
93
|
0
|
|
|
|
|
|
my $map_size = scalar @map; |
94
|
0
|
|
|
|
|
|
my $scale = $map_size ** 2 - 1; |
95
|
0
|
|
|
|
|
|
my $result = ''; |
96
|
0
|
|
|
|
|
|
for my $data (@{$self->data}) { |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $v = '__'; |
98
|
|
|
|
|
|
|
# if (defined $data && looks_like_number($data)) { |
99
|
0
|
|
|
|
|
|
my $normalized = int((($data - $min) * $scale) / abs($max - $min)); |
100
|
0
|
0
|
|
|
|
|
if ($normalized < 0) { |
|
|
0
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$normalized = 0; |
102
|
|
|
|
|
|
|
} elsif ($normalized >= $scale) { |
103
|
0
|
|
|
|
|
|
$normalized = $scale - 1; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$v = $map[ int($normalized / $map_size) ] . $map[ int($normalized % $map_size) ]; |
107
|
|
|
|
|
|
|
# } |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$result .= $v; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
|
return $result; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Google::Chart::Data::Extended - Google::Chart Extended Data Encoding |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SYNOPSIS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 METHODS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 parameter_value |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |