File Coverage

blib/lib/Excel/Writer/XLSX/Chart/Radar.pm
Criterion Covered Total %
statement 46 46 100.0
branch 8 8 100.0
condition 2 2 100.0
subroutine 9 9 100.0
pod 0 1 0.0
total 65 66 98.4


line stmt bran cond sub pod time code
1             package Excel::Writer::XLSX::Chart::Radar;
2              
3             ###############################################################################
4             #
5             # Radar - A class for writing Excel Radar 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-2020, 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 6     6   117 use 5.008002;
  6         20  
19 6     6   30 use strict;
  6         11  
  6         117  
20 6     6   26 use warnings;
  6         10  
  6         138  
21 6     6   26 use Carp;
  6         10  
  6         327  
22 6     6   35 use Excel::Writer::XLSX::Chart;
  6         11  
  6         2453  
23              
24             our @ISA = qw(Excel::Writer::XLSX::Chart);
25             our $VERSION = '1.07';
26              
27              
28             ###############################################################################
29             #
30             # new()
31             #
32             #
33             sub new {
34              
35 6     6 0 17 my $class = shift;
36 6         65 my $self = Excel::Writer::XLSX::Chart->new( @_ );
37              
38 6   100     29 $self->{_subtype} = $self->{_subtype} || 'marker';
39              
40 6 100       19 if ( $self->{_subtype} eq 'marker' ) {
41 4         9 $self->{_default_marker} = { type => 'none' };
42             }
43              
44             # Override and reset the default axis values.
45 6         19 $self->{_x_axis}->{_defaults}->{major_gridlines} = { visible => 1 };
46 6         31 $self->set_x_axis();
47              
48             # Hardcode major_tick_mark for now until there is an accessor.
49 6         13 $self->{_y_axis}->{_major_tick_mark} = 'cross';
50              
51             # Set the available data label positions for this chart type.
52 6         12 $self->{_label_position_default} = 'center';
53 6         16 $self->{_label_positions} = { center => 'ctr' };
54              
55 6         13 bless $self, $class;
56              
57 6         21 return $self;
58             }
59              
60              
61             ##############################################################################
62             #
63             # _write_chart_type()
64             #
65             # Override the virtual superclass method with a chart specific method.
66             #
67             sub _write_chart_type {
68              
69 12     12   22 my $self = shift;
70              
71             # Write the c:radarChart element.
72 12         41 $self->_write_radar_chart( @_ );
73             }
74              
75              
76             ##############################################################################
77             #
78             # _write_radar_chart()
79             #
80             # Write the element.
81             #
82             sub _write_radar_chart {
83              
84 12     12   18 my $self = shift;
85 12         33 my %args = @_;
86              
87 12         37 my @series;
88 12 100       35 if ( $args{primary_axes} ) {
89 6         57 @series = $self->_get_primary_axes_series;
90             }
91             else {
92 6         42 @series = $self->_get_secondary_axes_series;
93             }
94              
95 12 100       65 return unless scalar @series;
96              
97 6         34 $self->xml_start_tag( 'c:radarChart' );
98              
99             # Write the c:radarStyle element.
100 6         23 $self->_write_radar_style();
101              
102             # Write the series elements.
103 6         47 $self->_write_series( $_ ) for @series;
104              
105             # Write the c:axId elements
106 6         71 $self->_write_axis_ids( %args );
107              
108 6         23 $self->xml_end_tag( 'c:radarChart' );
109             }
110              
111              
112             ##############################################################################
113             #
114             # _write_radar_style()
115             #
116             # Write the element.
117             #
118             sub _write_radar_style {
119              
120 6     6   10 my $self = shift;
121 6         21 my $val = 'marker';
122              
123 6 100       23 if ( $self->{_subtype} eq 'filled' ) {
124 1         2 $val = 'filled';
125             }
126              
127 6         20 my @attributes = ( 'val' => $val );
128              
129 6         27 $self->xml_empty_tag( 'c:radarStyle', @attributes );
130             }
131              
132              
133             1;
134              
135              
136             __END__