line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Renderer::Point; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Renderer::Point::VERSION = '2.88'; |
3
|
7
|
|
|
7
|
|
29360
|
use Moose; |
|
7
|
|
|
|
|
538655
|
|
|
7
|
|
|
|
|
58
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Point renderer |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Chart::Clicker::Renderer'; |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
74129
|
use Geometry::Primitive::Circle; |
|
7
|
|
|
|
|
1931832
|
|
|
7
|
|
|
|
|
446
|
|
10
|
7
|
|
|
7
|
|
74
|
use Geometry::Primitive::Point; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
169
|
|
11
|
7
|
|
|
7
|
|
17388
|
use Graphics::Primitive::Operation::Fill; |
|
7
|
|
|
|
|
937482
|
|
|
7
|
|
|
|
|
344
|
|
12
|
7
|
|
|
7
|
|
17623
|
use Graphics::Primitive::Paint::Solid; |
|
7
|
|
|
|
|
482023
|
|
|
7
|
|
|
|
|
6601
|
|
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 $height = $self->height; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my @vals = @{ $series->values }; |
53
|
|
|
|
|
|
|
my @keys = @{ $series->keys }; |
54
|
|
|
|
|
|
|
for(0..($series->key_count - 1)) { |
55
|
|
|
|
|
|
|
my $x = $domain->mark($width, $keys[$_]); |
56
|
|
|
|
|
|
|
next unless defined($x); |
57
|
|
|
|
|
|
|
my $ymark = $range->mark($height, $vals[$_]); |
58
|
|
|
|
|
|
|
next unless defined($ymark); |
59
|
|
|
|
|
|
|
my $y = $height - $ymark; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->move_to($x, $y); |
62
|
|
|
|
|
|
|
$self->draw_point($x, $y, $series, $_); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
my $op = Graphics::Primitive::Operation::Fill->new( |
65
|
|
|
|
|
|
|
paint => Graphics::Primitive::Paint::Solid->new( |
66
|
|
|
|
|
|
|
color => $clicker->color_allocator->next |
67
|
|
|
|
|
|
|
) |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
if(defined($self->shape_brush)) { |
70
|
|
|
|
|
|
|
$op->preserve(1); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
$self->do($op); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
if(defined($self->shape_brush)) { |
75
|
|
|
|
|
|
|
my $op3 = Graphics::Primitive::Operation::Stroke->new; |
76
|
|
|
|
|
|
|
$op3->brush($self->shape_brush->clone); |
77
|
|
|
|
|
|
|
$self->do($op3); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return 1; |
83
|
|
|
|
|
|
|
}); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub draw_point { |
87
|
0
|
|
|
0
|
1
|
|
my ($self, $x, $y, $series, $count) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $shape = $self->shape->clone; |
90
|
0
|
|
|
|
|
|
$shape->origin(Geometry::Primitive::Point->new(x => $x, y => $y)); |
91
|
0
|
|
|
|
|
|
$self->path->add_primitive($shape); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
95
|
|
|
|
|
|
|
|
96
|
7
|
|
|
7
|
|
79
|
no Moose; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
53
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=pod |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Chart::Clicker::Renderer::Point - Point renderer |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
version 2.88 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SYNOPSIS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $pr = Chart::Clicker::Renderer::Point->new({ |
115
|
|
|
|
|
|
|
shape => Geometry::Primitive::Arc->new({ |
116
|
|
|
|
|
|
|
angle1 => 0, |
117
|
|
|
|
|
|
|
angle2 => 180, |
118
|
|
|
|
|
|
|
radius => 5 |
119
|
|
|
|
|
|
|
}) |
120
|
|
|
|
|
|
|
}); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Chart::Clicker::Renderer::Point renders a dataset as points. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=for HTML <p><img src="http://gphat.github.com/chart-clicker/static/images/examples/point.png" width="500" height="250" alt="Point Chart" /></p> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 shape |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Specify the L<shape|Geometry::Primitive::Shape> to be used at each point. Defaults to 360 degree arc with |
133
|
|
|
|
|
|
|
a radius of 3. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 shape_brush |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Optionally provide a L<brush|Graphics::Primitive::Brush> with with to stroke each point. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 METHODS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 draw_point |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Called for each point. Implemented as a separate method so that subclasses |
144
|
|
|
|
|
|
|
such as Bubble may override the drawing. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Cold Hard Code, LLC. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
155
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |