File Coverage

blib/lib/Chart/OFC/XAxis.pm
Criterion Covered Total %
statement 28 28 100.0
branch 12 12 100.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 47 47 100.0


line stmt bran cond sub pod time code
1             package Chart::OFC::XAxis;
2             $Chart::OFC::XAxis::VERSION = '0.12';
3 17     17   27555 use strict;
  17         35  
  17         732  
4 17     17   172 use warnings;
  17         35  
  17         635  
5              
6 17     17   1192 use Moose;
  17         467517  
  17         141  
7 17     17   83688 use MooseX::StrictConstructor;
  17         29514  
  17         166  
8 17     17   59947 use Chart::OFC::Types;
  17         41  
  17         6504  
9              
10             extends 'Chart::OFC::Axis';
11              
12              
13             has labels =>
14             ( is => 'ro',
15             isa => 'Chart::OFC::Type::NonEmptyArrayRef',
16             predicate => '_has_labels',
17             );
18              
19             has label_steps =>
20             ( is => 'ro',
21             isa => 'Chart::OFC::Type::PosInt',
22             default => 1,
23             );
24              
25             has tick_steps =>
26             ( is => 'ro',
27             isa => 'Chart::OFC::Type::PosInt',
28             predicate => '_has_tick_steps',
29             );
30              
31             has three_d_height =>
32             ( is => 'ro',
33             isa => 'Chart::OFC::Type::PosInt',
34             predicate => '_has_three_d_height',
35             );
36              
37             has orientation =>
38             ( is => 'ro',
39             isa => 'Chart::OFC::Type::Orientation',
40             default => 'horizontal',
41             );
42              
43             my %Orientation = ( horizontal => 0,
44             vertical => 1,
45             diagonal => 2,
46             );
47             sub _ofc_data_lines
48             {
49 13     13   72 my $self = shift;
50              
51 13         464 my @lines = $self->axis_label()->_ofc_data_lines('x');
52              
53 13 100       499 push @lines, $self->_data_line( 'x_labels', @{ $self->labels() } )
  3         112  
54             if $self->_has_labels();
55              
56 13 100       422 push @lines, $self->_data_line( 'x_label_style',
57             $self->text_size(),
58             $self->text_color(),
59             $Orientation{ $self->orientation() },
60             $self->label_steps(),
61             ( $self->_has_grid_color() ? $self->grid_color() : () ),
62             );
63              
64 13 100       509 push @lines, $self->_data_line( 'x_ticks', $self->tick_steps() )
65             if $self->_has_tick_steps();
66              
67 13 100       513 push @lines, $self->_data_line( 'x_axis_3d', $self->three_d_height() )
68             if $self->_has_three_d_height();
69              
70 13 100       502 push @lines, $self->_data_line( 'x_axis_color', $self->axis_color() )
71             if $self->_has_axis_color();
72              
73 13 100       478 push @lines, $self->_data_line( 'x_axis_steps', $self->tick_steps() )
74             if $self->_has_tick_steps();
75              
76 13         211 return @lines;
77             }
78              
79 17     17   128 no Moose;
  17         36  
  17         119  
80              
81             __PACKAGE__->meta()->make_immutable();
82              
83             1;
84              
85              
86             # ABSTRACT: X axis for grid charts
87              
88             __END__
89              
90             =pod
91              
92             =head1 NAME
93              
94             Chart::OFC::XAxis - X axis for grid charts
95              
96             =head1 VERSION
97              
98             version 0.12
99              
100             =head1 DESCRIPTION
101              
102             This class represents the X axis for a grid chart.
103              
104             =head1 ATTRIBUTES
105              
106             This class is a subclass of C<Chart::OFC::Axis> and accepts all of
107             that class's attribute. It has several attributes of its own which may
108             be passed to the C<new()> method.
109              
110             =head2 labels
111              
112             This should be an array reference containing one or more labels for
113             the X axis.
114              
115             This attribute is optional.
116              
117             =head2 label_steps
118              
119             Show a label every N values.
120              
121             This defaults to 1, but you should change this for large datasets.
122              
123             =head2 tick_steps
124              
125             Show a tick every N values.
126              
127             This attribute is optional. OFC seems to do a reasonably good job of
128             calculating a default.
129              
130             =head2 three_d_height
131              
132             Setting this to some integer makes the X axis display with a 3D
133             effect. You should set this if your chart contains 3D bars.
134              
135             =head2 orientation
136              
137             This can be one of "horizontal", "vertical", or "diagonal". According
138             to the OFC docs, Unicode characters will only display properly
139             horizontally.
140              
141             Defaults to "horizontal".
142              
143             =head1 ROLES
144              
145             This class does the C<Chart::OFC::Role::OFCDataLines> role.
146              
147             =head1 AUTHOR
148              
149             Dave Rolsky <autarch@urth.org>
150              
151             =head1 COPYRIGHT AND LICENSE
152              
153             This software is Copyright (c) 2014 by Dave Rolsky.
154              
155             This is free software, licensed under:
156              
157             The Artistic License 2.0 (GPL Compatible)
158              
159             =cut