line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Decoration::Legend; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Decoration::Legend::VERSION = '2.90'; |
3
|
8
|
|
|
8
|
|
59644
|
use Moose; |
|
8
|
|
|
|
|
397634
|
|
|
8
|
|
|
|
|
61
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Chart::Clicker::Container'; |
6
|
|
|
|
|
|
|
with 'Graphics::Primitive::Oriented'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Series name, color key |
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
47742
|
use Graphics::Primitive::Font; |
|
8
|
|
|
|
|
252182
|
|
|
8
|
|
|
|
|
527
|
|
11
|
8
|
|
|
8
|
|
870
|
use Graphics::Primitive::Insets; |
|
8
|
|
|
|
|
49365
|
|
|
8
|
|
|
|
|
248
|
|
12
|
8
|
|
|
8
|
|
5231
|
use Graphics::Primitive::TextBox; |
|
8
|
|
|
|
|
1806260
|
|
|
8
|
|
|
|
|
391
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
5603
|
use Layout::Manager::Flow; |
|
8
|
|
|
|
|
275779
|
|
|
8
|
|
|
|
|
3287
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '+border' => ( |
18
|
|
|
|
|
|
|
default => sub { |
19
|
|
|
|
|
|
|
my $b = Graphics::Primitive::Border->new; |
20
|
|
|
|
|
|
|
$b->color(Graphics::Color::RGB->new( red => 0, green => 0, blue => 0)); |
21
|
|
|
|
|
|
|
$b->width(1); |
22
|
|
|
|
|
|
|
return $b; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'font' => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => 'Graphics::Primitive::Font', |
30
|
|
|
|
|
|
|
default => sub { |
31
|
|
|
|
|
|
|
Graphics::Primitive::Font->new |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'item_padding' => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
isa => 'Graphics::Primitive::Insets', |
39
|
|
|
|
|
|
|
default => sub { |
40
|
|
|
|
|
|
|
Graphics::Primitive::Insets->new({ |
41
|
|
|
|
|
|
|
top => 3, left => 3, bottom => 3, right => 5 |
42
|
|
|
|
|
|
|
}) |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has '+layout_manager' => ( |
48
|
|
|
|
|
|
|
default => sub { Layout::Manager::Flow->new(anchor => 'west', wrap => 1) }, |
49
|
|
|
|
|
|
|
lazy => 1 |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
override('prepare', sub { |
53
|
|
|
|
|
|
|
my ($self, $driver) = @_; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return if $self->component_count > 0; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $ca = $self->clicker->color_allocator; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $font = $self->font; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $ii = $self->item_padding; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#this makes sure that wrapping works |
64
|
|
|
|
|
|
|
$self->width($self->clicker->width); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
if($self->is_vertical) { |
67
|
|
|
|
|
|
|
# This assumes you aren't changing the layout manager... |
68
|
|
|
|
|
|
|
$self->layout_manager->anchor('north'); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $count = 0; |
72
|
|
|
|
|
|
|
foreach my $ds (@{ $self->clicker->datasets }) { |
73
|
|
|
|
|
|
|
foreach my $s (@{ $ds->series }) { |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
unless($s->has_name) { |
76
|
|
|
|
|
|
|
$s->name("Series $count"); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $tb = Graphics::Primitive::TextBox->new( |
80
|
|
|
|
|
|
|
color => $ca->next, |
81
|
|
|
|
|
|
|
font => $font, |
82
|
|
|
|
|
|
|
padding => $ii, |
83
|
|
|
|
|
|
|
text => $s->name |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$self->add_component($tb); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$count++; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
super; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$ca->reset; |
95
|
|
|
|
|
|
|
}); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
98
|
|
|
|
|
|
|
|
99
|
8
|
|
|
8
|
|
93
|
no Moose; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
80
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=pod |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Chart::Clicker::Decoration::Legend - Series name, color key |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
version 2.90 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 DESCRIPTION |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Chart::Clicker::Decoration::Legend draws a legend on a Chart. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 border |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Set/Get this Legend's L<border|Graphics::Primitive::Border>. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 font |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Set/Get the L<font|Graphics::Primitive::Font> used for this legend's items. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 insets |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Set/Get this Legend's L<insets|Graphics::Primitive::Insets>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 item_padding |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Set/Get the L<padding|Graphics::Primitive::Insets> for this legend's items. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 layout_manager |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Set/Get the layout manager for this lagend. Defaults to |
140
|
|
|
|
|
|
|
L<Layout::Manager::Flow> with an anchor of C<west> and a C<wrap> of 1. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Cory G Watson. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
151
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |