OFC/Pie.pm

filter: Statementstmt 100% 42 / 42 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 94.7% 54 / 57 CC 3 SCAR 2.9
CC
3
Cov
96%
_formatted_label_style
2.0
BUILD
2.0
BEGIN
1.0
CRAP 1.3
« OFC/Dataset/LineWithDots.pm ↑ Summary OFC/Dataset/OutlinedBar.pm »
1 package Chart::OFC::Pie;
2 19 $Chart::OFC::Pie::VERSION = '0.12';
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 19 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 ▶use Chart::OFC::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 19 extends 'Chart::OFC';
11  
12 19 has dataset =>
13 ( is => 'ro',
14 isa => 'Chart::OFC::Dataset',
15 required => 1,
16 );
17  
18 has slice_colors =>
19 ( is => 'ro',
20 isa => 'Chart::OFC::Type::NonEmptyArrayRefOfColors',
21 coerce => 1,
22 lazy => 1,
23 2 ▶ default => sub { [ qw( red blue green yellow orange purple black ) ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 19 );
25  
26 19 has line_color =>
27 ( is => 'ro',
28 isa => 'Chart::OFC::Type::Color',
29 coerce => 1,
30 default => '#000000',
31 );
32  
33 19 has labels =>
34 ( is => 'ro',
35 isa => 'Chart::OFC::Type::NonEmptyArrayRef',
36 required => 1,
37 auto_deref => 1,
38 );
39  
40 19 has label_style =>
41 ( is => 'ro',
42 isa => 'Str',
43 default => 'color: #000000',
44 );
45  
46 19 has opacity =>
47 ( is => 'ro',
48 isa => 'Chart::OFC::Type::Opacity',
49 default => '80',
50 );
51  
52 sub BUILD
53 2 ▶{
Subroutine BUILD: called CC=2 SCAR=7.0
Pod undocumented
54 2 my $self = shift;
55  
56 2 my @l = $self->labels();
57 2 my @v = $self->dataset()->values();
58  
59 2 ▶ die 'You must have the same number of labels and values.'
Branch: 1 branch
BranchTrueFalseTotal
unless @l == @v 0 2 2
60 unless @l == @v;
61  
62 2 return;
63 }
64  
65 override _ofc_data_lines => sub
66 2 ▶{
Subroutine __ANON__: called CC=1 SCAR=0.0
67 2 my $self = shift;
68  
69 return
70 ( super(),
71 $self->_data_line( 'pie',
72 $self->opacity(),
73 $self->line_color(),
74 $self->_formatted_label_style(),
75 ),
76 $self->_data_line( 'pie_labels', $self->labels() ),
77 2 $self->_data_line( 'colours', @{ $self->slice_colors() } ),
78 $self->dataset()->_ofc_data_lines(),
79 );
80 19 };
81  
82 sub _formatted_label_style
83 2 ▶{
Subroutine _formatted_label_style: called CC=2 SCAR=7.0
84 2 my $self = shift;
85  
86 2 my $style = $self->label_style();
87  
88 2 ▶ return unless length $style;
Branch: 1 branch
BranchTrueFalseTotal
unless length $style 0 2 2
89  
90 2 return '{ ' . $self->label_style() . ' }';
91 }
92  
93 19 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95 19 __PACKAGE__->meta()->make_immutable();
96  
97 19 1;
98  
99 # ABSTRACT: A pie chart
100  
101 __END__
« OFC/Dataset/LineWithDots.pm ↑ Summary OFC/Dataset/OutlinedBar.pm »