line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Renderer::Point; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Renderer::Point::VERSION = '2.90'; |
3
|
7
|
|
|
7
|
|
63274
|
use Moose; |
|
7
|
|
|
|
|
358099
|
|
|
7
|
|
|
|
|
59
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Point renderer |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Chart::Clicker::Renderer'; |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
41100
|
use Geometry::Primitive::Circle; |
|
7
|
|
|
|
|
1358288
|
|
|
7
|
|
|
|
|
349
|
|
10
|
7
|
|
|
7
|
|
61
|
use Geometry::Primitive::Point; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
171
|
|
11
|
7
|
|
|
7
|
|
5222
|
use Graphics::Primitive::Operation::Fill; |
|
7
|
|
|
|
|
616454
|
|
|
7
|
|
|
|
|
455
|
|
12
|
7
|
|
|
7
|
|
6066
|
use Graphics::Primitive::Paint::Solid; |
|
7
|
|
|
|
|
247346
|
|
|
7
|
|
|
|
|
3447
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'shape' => ( |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
does => 'Geometry::Primitive::Shape', |
18
|
|
|
|
|
|
|
default => sub { |
19
|
|
|
|
|
|
|
Geometry::Primitive::Circle->new({ |
20
|
|
|
|
|
|
|
radius => 3, |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'shape_brush' => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => 'Graphics::Primitive::Brush', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
override('finalize', sub { |
32
|
|
|
|
|
|
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $clicker = $self->clicker; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $width = $self->width; |
37
|
|
|
|
|
|
|
my $height = $self->height; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $dses = $clicker->get_datasets_for_context($self->context); |
40
|
|
|
|
|
|
|
foreach my $ds (@{ $dses }) { |
41
|
|
|
|
|
|
|
foreach my $series (@{ $ds->series }) { |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# TODO if undef... |
44
|
|
|
|
|
|
|
my $ctx = $clicker->get_context($ds->context); |
45
|
|
|
|
|
|
|
my $domain = $ctx->domain_axis; |
46
|
|
|
|
|
|
|
my $range = $ctx->range_axis; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $min = $range->range->lower; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my @vals = @{ $series->values }; |
51
|
|
|
|
|
|
|
my @keys = @{ $series->keys }; |
52
|
|
|
|
|
|
|
for(0..($series->key_count - 1)) { |
53
|
|
|
|
|
|
|
my $x = $domain->mark($width, $keys[$_]); |
54
|
|
|
|
|
|
|
next unless defined($x); |
55
|
|
|
|
|
|
|
my $ymark = $range->mark($height, $vals[$_]); |
56
|
|
|
|
|
|
|
next unless defined($ymark); |
57
|
|
|
|
|
|
|
my $y = $height - $ymark; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$self->move_to($x, $y); |
60
|
|
|
|
|
|
|
$self->draw_point($x, $y, $series, $_); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
my $op = Graphics::Primitive::Operation::Fill->new( |
63
|
|
|
|
|
|
|
paint => Graphics::Primitive::Paint::Solid->new( |
64
|
|
|
|
|
|
|
color => $clicker->color_allocator->next |
65
|
|
|
|
|
|
|
) |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
if(defined($self->shape_brush)) { |
68
|
|
|
|
|
|
|
$op->preserve(1); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
$self->do($op); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if(defined($self->shape_brush)) { |
73
|
|
|
|
|
|
|
my $op3 = Graphics::Primitive::Operation::Stroke->new; |
74
|
|
|
|
|
|
|
$op3->brush($self->shape_brush->clone); |
75
|
|
|
|
|
|
|
$self->do($op3); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return 1; |
81
|
|
|
|
|
|
|
}); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub draw_point { |
85
|
0
|
|
|
0
|
1
|
|
my ($self, $x, $y, $series, $count) = @_; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $shape = $self->shape->clone; |
88
|
0
|
|
|
|
|
|
$shape->origin(Geometry::Primitive::Point->new(x => $x, y => $y)); |
89
|
0
|
|
|
|
|
|
$self->path->add_primitive($shape); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
93
|
|
|
|
|
|
|
|
94
|
7
|
|
|
7
|
|
64
|
no Moose; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
45
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Chart::Clicker::Renderer::Point - Point renderer |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 VERSION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
version 2.90 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SYNOPSIS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $pr = Chart::Clicker::Renderer::Point->new({ |
113
|
|
|
|
|
|
|
shape => Geometry::Primitive::Arc->new({ |
114
|
|
|
|
|
|
|
angle1 => 0, |
115
|
|
|
|
|
|
|
angle2 => 180, |
116
|
|
|
|
|
|
|
radius => 5 |
117
|
|
|
|
|
|
|
}) |
118
|
|
|
|
|
|
|
}); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 DESCRIPTION |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Chart::Clicker::Renderer::Point renders a dataset as points. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=for HTML <p><img src="http://gphat.github.com/chart-clicker/static/images/examples/point.png" width="500" height="250" alt="Point Chart" /></p> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 shape |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Specify the L<shape|Geometry::Primitive::Shape> to be used at each point. Defaults to 360 degree arc with |
131
|
|
|
|
|
|
|
a radius of 3. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 shape_brush |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Optionally provide a L<brush|Graphics::Primitive::Brush> with with to stroke each point. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 METHODS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 draw_point |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Called for each point. Implemented as a separate method so that subclasses |
142
|
|
|
|
|
|
|
such as Bubble may override the drawing. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Cory G Watson. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
153
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |