File Coverage

blib/lib/Excel/Writer/XLSX/Chart/Area.pm
Criterion Covered Total %
statement 43 43 100.0
branch 8 8 100.0
condition 2 2 100.0
subroutine 8 8 100.0
pod 0 1 0.0
total 61 62 98.3


line stmt bran cond sub pod time code
1             package Excel::Writer::XLSX::Chart::Area;
2              
3             ###############################################################################
4             #
5             # Area - A class for writing Excel Area charts.
6             #
7             # Used in conjunction with Excel::Writer::XLSX::Chart.
8             #
9             # See formatting note in Excel::Writer::XLSX::Chart.
10             #
11             # Copyright 2000-2019, John McNamara, jmcnamara@cpan.org
12             #
13             # Documentation after __END__
14             #
15              
16             # perltidy with the following options: -mbl=2 -pt=0 -nola
17              
18 11     11   3157 use 5.008002;
  11         39  
19 11     11   57 use strict;
  11         22  
  11         218  
20 11     11   51 use warnings;
  11         21  
  11         283  
21 11     11   55 use Carp;
  11         22  
  11         708  
22 11     11   74 use Excel::Writer::XLSX::Chart;
  11         38  
  11         4135  
23              
24             our @ISA = qw(Excel::Writer::XLSX::Chart);
25             our $VERSION = '1.03';
26              
27              
28             ###############################################################################
29             #
30             # new()
31             #
32             #
33             sub new {
34              
35 11     11 0 875 my $class = shift;
36 11         66 my $self = Excel::Writer::XLSX::Chart->new( @_ );
37              
38 11   100     54 $self->{_subtype} = $self->{_subtype} || 'standard';
39 11         25 $self->{_cross_between} = 'midCat';
40 11         19 $self->{_show_crosses} = 0;
41              
42             # Override and reset the default axis values.
43 11 100       45 if ( $self->{_subtype} eq 'percent_stacked' ) {
44 1         2 $self->{_y_axis}->{_defaults}->{num_format} = '0%';
45             }
46              
47 11         48 $self->set_y_axis();
48              
49             # Sset the available data label positions for this chart type.
50 11         20 $self->{_label_position_default} = 'center';
51 11         34 $self->{_label_positions} = { center => 'ctr' };
52              
53 11         30 bless $self, $class;
54 11         36 return $self;
55             }
56              
57              
58             ##############################################################################
59             #
60             # _write_chart_type()
61             #
62             # Override the virtual superclass method with a chart specific method.
63             #
64             sub _write_chart_type {
65              
66 20     20   33 my $self = shift;
67              
68             # Write the c:areaChart element.
69 20         69 $self->_write_area_chart( @_ );
70             }
71              
72              
73             ##############################################################################
74             #
75             # _write_area_chart()
76             #
77             # Write the element.
78             #
79             sub _write_area_chart {
80              
81 20     20   44 my $self = shift;
82 20         53 my %args = @_;
83              
84 20         39 my @series;
85 20 100       65 if ( $args{primary_axes} ) {
86 10         82 @series = $self->_get_primary_axes_series;
87             }
88             else {
89 10         80 @series = $self->_get_secondary_axes_series;
90             }
91              
92 20 100       78 return unless scalar @series;
93              
94 11         27 my $subtype = $self->{_subtype};
95              
96 11 100       33 $subtype = 'percentStacked' if $subtype eq 'percent_stacked';
97              
98 11         47 $self->xml_start_tag( 'c:areaChart' );
99              
100             # Write the c:grouping element.
101 11         78 $self->_write_grouping( $subtype );
102              
103             # Write the series elements.
104 11         78 $self->_write_series( $_ ) for @series;
105              
106             # Write the c:dropLines element.
107 11         108 $self->_write_drop_lines();
108              
109             # Write the c:axId elements
110 11         156 $self->_write_axis_ids( %args );
111              
112 11         51 $self->xml_end_tag( 'c:areaChart' );
113             }
114              
115              
116             1;
117              
118              
119             __END__