line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Decoration::Legend; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Decoration::Legend::VERSION = '2.88'; |
3
|
8
|
|
|
8
|
|
21961
|
use Moose; |
|
8
|
|
|
|
|
453202
|
|
|
8
|
|
|
|
|
71
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Chart::Clicker::Container'; |
6
|
|
|
|
|
|
|
with 'Graphics::Primitive::Oriented'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Series name, color key |
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
56660
|
use Graphics::Primitive::Font; |
|
8
|
|
|
|
|
341163
|
|
|
8
|
|
|
|
|
318
|
|
11
|
8
|
|
|
8
|
|
1195
|
use Graphics::Primitive::Insets; |
|
8
|
|
|
|
|
65138
|
|
|
8
|
|
|
|
|
228
|
|
12
|
8
|
|
|
8
|
|
8298
|
use Graphics::Primitive::TextBox; |
|
8
|
|
|
|
|
2410849
|
|
|
8
|
|
|
|
|
388
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
8282
|
use Layout::Manager::Flow; |
|
8
|
|
|
|
|
344225
|
|
|
8
|
|
|
|
|
3946
|
|
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
|
|
94
|
no Moose; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
60
|
|
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.88 |
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) 2014 by Cold Hard Code, LLC. |
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 |