line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Renderer::Area; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Renderer::Area::VERSION = '2.89'; |
3
|
1
|
|
|
1
|
|
64507
|
use Moose; |
|
1
|
|
|
|
|
379894
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Chart::Clicker::Renderer'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Area renderer |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6285
|
use Graphics::Primitive::Brush; |
|
1
|
|
|
|
|
243774
|
|
|
1
|
|
|
|
|
41
|
|
10
|
1
|
|
|
1
|
|
684
|
use Graphics::Primitive::Path; |
|
1
|
|
|
|
|
492324
|
|
|
1
|
|
|
|
|
44
|
|
11
|
1
|
|
|
1
|
|
735
|
use Graphics::Primitive::Operation::Fill; |
|
1
|
|
|
|
|
40131
|
|
|
1
|
|
|
|
|
70
|
|
12
|
1
|
|
|
1
|
|
977
|
use Graphics::Primitive::Operation::Stroke; |
|
1
|
|
|
|
|
27045
|
|
|
1
|
|
|
|
|
62
|
|
13
|
1
|
|
|
1
|
|
771
|
use Graphics::Primitive::Paint::Gradient::Linear; |
|
1
|
|
|
|
|
185491
|
|
|
1
|
|
|
|
|
45
|
|
14
|
1
|
|
|
1
|
|
698
|
use Graphics::Primitive::Paint::Solid; |
|
1
|
|
|
|
|
24278
|
|
|
1
|
|
|
|
|
611
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'brush' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Graphics::Primitive::Brush', |
20
|
|
|
|
|
|
|
default => sub { Graphics::Primitive::Brush->new } |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'fade' => ( |
25
|
|
|
|
|
|
|
is => 'rw', |
26
|
|
|
|
|
|
|
isa => 'Bool', |
27
|
|
|
|
|
|
|
default => 0 |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'opacity' => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
isa => 'Num', |
34
|
|
|
|
|
|
|
default => 0 |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
override('finalize', sub { |
38
|
|
|
|
|
|
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $height = $self->height; |
41
|
|
|
|
|
|
|
my $width = $self->width; |
42
|
|
|
|
|
|
|
my $clicker = $self->clicker; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $dses = $clicker->get_datasets_for_context($self->context); |
45
|
|
|
|
|
|
|
foreach my $ds (@{ $dses }) { |
46
|
|
|
|
|
|
|
foreach my $series (@{ $ds->series }) { |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# TODO if undef... |
49
|
|
|
|
|
|
|
my $ctx = $clicker->get_context($ds->context); |
50
|
|
|
|
|
|
|
my $domain = $ctx->domain_axis; |
51
|
|
|
|
|
|
|
my $range = $ctx->range_axis; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $lastx; # used for completing the path |
54
|
|
|
|
|
|
|
my @vals = @{ $series->values }; |
55
|
|
|
|
|
|
|
my @keys = @{ $series->keys }; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $startx; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $biggest; |
60
|
|
|
|
|
|
|
for(0..($series->key_count - 1)) { |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $x = $domain->mark($width, $keys[$_]); |
63
|
|
|
|
|
|
|
next unless defined($x); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $ymark = $range->mark($height, $vals[$_]); |
66
|
|
|
|
|
|
|
next unless defined($ymark); |
67
|
|
|
|
|
|
|
my $y = $height - $ymark; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
if(defined($biggest)) { |
70
|
|
|
|
|
|
|
$biggest = $y if $y > $biggest; |
71
|
|
|
|
|
|
|
} else { |
72
|
|
|
|
|
|
|
$biggest = $y; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
if($_ == 0) { |
76
|
|
|
|
|
|
|
$startx = $x; |
77
|
|
|
|
|
|
|
$self->move_to($x, $y); |
78
|
|
|
|
|
|
|
} else { |
79
|
|
|
|
|
|
|
$self->line_to($x, $y); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
$lastx = $x; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
my $color = $self->clicker->color_allocator->next; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $op = Graphics::Primitive::Operation::Stroke->new; |
86
|
|
|
|
|
|
|
$op->preserve(1); |
87
|
|
|
|
|
|
|
$op->brush($self->brush->clone); |
88
|
|
|
|
|
|
|
$op->brush->color($color); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$self->do($op); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->line_to($lastx, $height); |
93
|
|
|
|
|
|
|
$self->line_to($startx, $height); |
94
|
|
|
|
|
|
|
$self->close_path; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $paint; |
97
|
|
|
|
|
|
|
if($self->opacity) { |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $clone = $color->clone; |
100
|
|
|
|
|
|
|
$clone->alpha($self->opacity); |
101
|
|
|
|
|
|
|
$paint = Graphics::Primitive::Paint::Solid->new( |
102
|
|
|
|
|
|
|
color => $clone |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} elsif($self->fade) { |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $clone = $color->clone; |
107
|
|
|
|
|
|
|
$clone->alpha($self->opacity); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$paint = Graphics::Primitive::Paint::Gradient::Linear->new( |
110
|
|
|
|
|
|
|
line => Geometry::Primitive::Line->new( |
111
|
|
|
|
|
|
|
start => Geometry::Primitive::Point->new(x => 0, y => 0), |
112
|
|
|
|
|
|
|
end => Geometry::Primitive::Point->new(x => 1, y => $biggest), |
113
|
|
|
|
|
|
|
), |
114
|
|
|
|
|
|
|
style => 'linear' |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
$paint->add_stop(1.0, $color); |
117
|
|
|
|
|
|
|
$paint->add_stop(0, $clone); |
118
|
|
|
|
|
|
|
} else { |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$paint = Graphics::Primitive::Paint::Solid->new( |
121
|
|
|
|
|
|
|
color => $color->clone |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
my $fillop = Graphics::Primitive::Operation::Fill->new( |
125
|
|
|
|
|
|
|
paint => $paint |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
$self->do($fillop); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return 1; |
133
|
|
|
|
|
|
|
}); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
1
|
|
8
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=pod |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 NAME |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Chart::Clicker::Renderer::Area - Area renderer |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 VERSION |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
version 2.89 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SYNOPSIS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $ar = Chart::Clicker::Renderer::Area->new({ |
156
|
|
|
|
|
|
|
fade => 1, |
157
|
|
|
|
|
|
|
brush => Graphics::Primitive::Brush->new({ |
158
|
|
|
|
|
|
|
width => 2 |
159
|
|
|
|
|
|
|
}) |
160
|
|
|
|
|
|
|
}); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 DESCRIPTION |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Chart::Clicker::Renderer::Area renders a dataset as line-like polygons with |
165
|
|
|
|
|
|
|
their interior areas filled. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=for HTML <p><img src="http://gphat.github.com/chart-clicker/static/images/examples/area.png" width="500" height="250" alt="Area Chart" /></p> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 brush |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Set/Get the L<brush|Graphics::Primitive::Brush> that informs the line surrounding the area renders |
174
|
|
|
|
|
|
|
individual segments. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 fade |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Set/Get the fade flag, which turns on or off a gradient in the area renderer. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 opacity |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Set the alpha value for the renderer, which makes things more or less opaque. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Cory G Watson. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
193
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |