File Coverage

blib/lib/Chart/OFC/Dataset/Bar.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             package Chart::OFC::Dataset::Bar;
2             $Chart::OFC::Dataset::Bar::VERSION = '0.12';
3 16     16   12758 use strict;
  16         40  
  16         597  
4 16     16   95 use warnings;
  16         39  
  16         472  
5              
6 16     16   93 use Moose;
  16         36  
  16         115  
7 16     16   110344 use MooseX::StrictConstructor;
  16         43  
  16         156  
8 16     16   50690 use Chart::OFC::Types;
  16         42  
  16         3614  
9              
10             extends 'Chart::OFC::Dataset';
11              
12             has opacity =>
13             ( is => 'ro',
14             isa => 'Chart::OFC::Type::Opacity',
15             default => '80',
16             );
17              
18             has fill_color =>
19             ( is => 'ro',
20             isa => 'Chart::OFC::Type::Color',
21             coerce => 1,
22             default => '#999999',
23             );
24              
25             has label =>
26             ( is => 'ro',
27             isa => 'Str',
28             predicate => '_has_label',
29             );
30              
31             has text_size =>
32             ( is => 'ro',
33             isa => 'Chart::OFC::Type::Size',
34             default => 10,
35             );
36              
37             sub type
38             {
39 9     9 0 26 return 'bar';
40             }
41              
42             sub _parameters_for_type
43             {
44 13     13   23 my $self = shift;
45              
46 13         503 my @p = ( $self->opacity(), $self->fill_color() );
47 13 100       538 push @p, ( $self->label(), $self->text_size() )
48             if $self->_has_label();
49              
50 13         94 return @p;
51             }
52              
53 16     16   105 no Moose;
  16         35  
  16         115  
54              
55             __PACKAGE__->meta()->make_immutable();
56              
57             1;
58              
59              
60             # ABSTRACT: A dataset represented as bars
61              
62             __END__
63              
64             =pod
65              
66             =head1 NAME
67              
68             Chart::OFC::Dataset::Bar - A dataset represented as bars
69              
70             =head1 VERSION
71              
72             version 0.12
73              
74             =head1 SYNOPSIS
75              
76             my @numbers = (1, 2, 3);
77             my $bars = Chart::OFC::Dataset::Bar->new(
78             values => \@numbers,
79             opacity => 60,
80             fill_color => 'purple',
81             label => 'Daily Sales in $',
82             text_size => 12,
83             );
84              
85             =head1 DESCRIPTION
86              
87             This class contains values to be charted as bars on a grid chart. The
88             bars are filled with the specified color, but have no outline or other
89             styling.
90              
91             =for Pod::Coverage type
92              
93             =head1 ATTRIBUTES
94              
95             This class has several attributes which may be passed to the C<new()>
96             method.
97              
98             It is a subclass of C<Chart::OFC::Dataset> and accepts all of that
99             class's attributes as well as its own.
100              
101             =head2 opacity
102              
103             This defines how opaque the bars are. When they are moused over, they
104             become fully opaque.
105              
106             Defaults to 80 (percent).
107              
108             =head2 fill_color
109              
110             The color used to fill the bars.
111              
112             Defaults to #999999 (medium grey).
113              
114             =head2 label
115              
116             If provided, this will be shown as part of the chart key. The label
117             will be the same color as the fill_color for the bars.
118              
119             This attribute is optional.
120              
121             =head2 text_size
122              
123             This is the size of the text in the key.
124              
125             Defaults to 10 (pixels).
126              
127             =head1 ROLES
128              
129             This class does the C<Chart::OFC::Role::OFCDataLines> role.
130              
131             =head1 AUTHOR
132              
133             Dave Rolsky <autarch@urth.org>
134              
135             =head1 COPYRIGHT AND LICENSE
136              
137             This software is Copyright (c) 2014 by Dave Rolsky.
138              
139             This is free software, licensed under:
140              
141             The Artistic License 2.0 (GPL Compatible)
142              
143             =cut