line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::OFC::Grid; |
2
|
|
|
|
|
|
|
$Chart::OFC::Grid::VERSION = '0.12'; |
3
|
16
|
|
|
16
|
|
40599
|
use strict; |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
725
|
|
4
|
16
|
|
|
16
|
|
99
|
use warnings; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
510
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
1146
|
use Moose; |
|
16
|
|
|
|
|
568471
|
|
|
16
|
|
|
|
|
132
|
|
7
|
16
|
|
|
16
|
|
113790
|
use MooseX::StrictConstructor; |
|
16
|
|
|
|
|
23857
|
|
|
16
|
|
|
|
|
175
|
|
8
|
16
|
|
|
16
|
|
64351
|
use Chart::OFC::Types; |
|
16
|
|
|
|
|
42
|
|
|
16
|
|
|
|
|
7259
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Chart::OFC'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has datasets => |
13
|
|
|
|
|
|
|
( is => 'ro', |
14
|
|
|
|
|
|
|
isa => 'Chart::OFC::Type::NonEmptyArrayRefOfTypedDatasets', |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has x_axis => |
19
|
|
|
|
|
|
|
( is => 'ro', |
20
|
|
|
|
|
|
|
isa => 'Chart::OFC::XAxis', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has y_axis => |
25
|
|
|
|
|
|
|
( is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Chart::OFC::YAxis', |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has inner_bg_color => |
31
|
|
|
|
|
|
|
( is => 'ro', |
32
|
|
|
|
|
|
|
isa => 'Chart::OFC::Type::Color', |
33
|
|
|
|
|
|
|
coerce => 1, |
34
|
|
|
|
|
|
|
predicate => '_has_inner_bg_color', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has inner_bg_color2 => |
38
|
|
|
|
|
|
|
( is => 'ro', |
39
|
|
|
|
|
|
|
isa => 'Chart::OFC::Type::Color', |
40
|
|
|
|
|
|
|
coerce => 1, |
41
|
|
|
|
|
|
|
predicate => '_has_inner_bg_color2', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has inner_bg_fade_angle => |
45
|
|
|
|
|
|
|
( is => 'ro', |
46
|
|
|
|
|
|
|
isa => 'Chart::OFC::Type::Angle', |
47
|
|
|
|
|
|
|
predicate => '_has_inner_bg_fade_angle', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub BUILD |
52
|
|
|
|
|
|
|
{ |
53
|
9
|
|
|
9
|
0
|
15
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
9
|
100
|
100
|
|
|
437
|
die "You cannot set an inner background fade angle unless you set two background colors" |
|
|
|
100
|
|
|
|
|
56
|
|
|
|
|
|
|
if $self->_has_inner_bg_fade_angle() |
57
|
|
|
|
|
|
|
&& ! ( $self->_has_inner_bg_color() && $self->_has_inner_bg_color2() ); |
58
|
|
|
|
|
|
|
|
59
|
6
|
100
|
100
|
|
|
247
|
die "You cannot set a second inner background color unless you set a first color and a fade angle" |
|
|
|
100
|
|
|
|
|
60
|
|
|
|
|
|
|
if $self->_has_inner_bg_color2() |
61
|
|
|
|
|
|
|
&& ! ( $self->_has_inner_bg_color() && $self->_has_inner_bg_fade_angle ); |
62
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
132
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
override _ofc_data_lines => sub |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $x = 1; |
71
|
|
|
|
|
|
|
return |
72
|
|
|
|
|
|
|
( super(), |
73
|
|
|
|
|
|
|
$self->_inner_background_line(), |
74
|
|
|
|
|
|
|
$self->x_axis()->_ofc_data_lines(), |
75
|
|
|
|
|
|
|
$self->y_axis()->_ofc_data_lines(), |
76
|
|
|
|
|
|
|
map { $_->_ofc_data_lines($x++) } @{ $self->datasets() }, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _inner_background_line |
81
|
|
|
|
|
|
|
{ |
82
|
4
|
|
|
4
|
|
8
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
4
|
100
|
|
|
|
188
|
return unless $self->_has_inner_bg_color(); |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
49
|
my @vals = $self->inner_bg_color(); |
87
|
|
|
|
|
|
|
|
88
|
1
|
50
|
|
|
|
42
|
if ( $self->_has_inner_bg_color2() ) |
89
|
|
|
|
|
|
|
{ |
90
|
1
|
|
|
|
|
31
|
push @vals, $self->inner_bg_color2(), $self->inner_bg_fade_angle(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
9
|
return $self->_data_line( 'inner_background', @vals ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
16
|
|
|
16
|
|
132
|
no Moose; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
108
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# ABSTRACT: A grid chart |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Chart::OFC::Grid - A grid chart |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 VERSION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
version 0.12 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $bars = Chart::OFC::Dataset::Bar->new( values => [ 1 .. 5 ] ); |
120
|
|
|
|
|
|
|
my $line = Chart::OFC::Dataset::Line->new( values => [ 2 .. 7 ] ); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $x_axis = Chart::OFC::XAxis->new( axis_label => 'X Axis' ); |
123
|
|
|
|
|
|
|
my $y_axis = Chart::OFC::YAxis->new( |
124
|
|
|
|
|
|
|
axis_label => 'Y Axis', |
125
|
|
|
|
|
|
|
max => 10, |
126
|
|
|
|
|
|
|
label_steps => 2 |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $grid = Chart::OFC::Grid->new( |
130
|
|
|
|
|
|
|
title => 'My Grid Chart', |
131
|
|
|
|
|
|
|
datasets => [ $bars, $line ], |
132
|
|
|
|
|
|
|
x_axis => $x_axis, |
133
|
|
|
|
|
|
|
y_axis => $y_axis, |
134
|
|
|
|
|
|
|
); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 DESCRIPTION |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This class represents a grid chart. A grid chart can contain any |
139
|
|
|
|
|
|
|
combination of bars, lines, and area lines. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
It also has an X and a Y axis. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=for Pod::Coverage BUILD |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This class is a subclass of C<Chart::OFC> and accepts all of that |
148
|
|
|
|
|
|
|
class's attribute. It has several attributes of its own which may be |
149
|
|
|
|
|
|
|
passed to the C<new()> method. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 datasets |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This should be an array reference containing at least one dataset. The |
154
|
|
|
|
|
|
|
datasets can be of any type I<except> C<Class::OFC::Dataset> (the base |
155
|
|
|
|
|
|
|
class). Instead, they must be objects of some Dataset subclass. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This attribute is required. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 x_axis |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This should be a C<Chart::OFC::XAxis> object. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This attribute is required. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 y_axis |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This should be a C<Chart::OFC::YAxis> object. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This attribute is required. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 inner_bg_color |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The background color for just the chart itself, as opposed to the |
174
|
|
|
|
|
|
|
surrounding text. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This attribute is optional. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 inner_bg_color2 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
If this is provided, then OFC will implement a fade between the two |
181
|
|
|
|
|
|
|
inner background colors. If you provide this you must also provide an |
182
|
|
|
|
|
|
|
C<inner_bg_fade_angle> attribute. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This attribute is optional. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 inner_bg_fade_angle |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
A number from 0 to 359 specifying the angle of the fade between the |
189
|
|
|
|
|
|
|
two background colors. If you provide this you must also provide two |
190
|
|
|
|
|
|
|
inner background colors. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This attribute is optional. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 ROLES |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This class does the C<Chart::OFC::Role::OFCDataLines> role. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 AUTHOR |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Dave Rolsky. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This is free software, licensed under: |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |