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-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 6     6   110 use 5.008002;
  6         21  
19 6     6   30 use strict;
  6         11  
  6         155  
20 6     6   29 use warnings;
  6         11  
  6         160  
21 6     6   28 use Carp;
  6         12  
  6         387  
22 6     6   37 use Excel::Writer::XLSX::Chart;
  6         17  
  6         2461  
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 6     6 0 16 my $class = shift;
36 6         35 my $self = Excel::Writer::XLSX::Chart->new( @_ );
37              
38 6   100     27 $self->{_subtype} = $self->{_subtype} || 'marker';
39              
40 6 100       18 if ( $self->{_subtype} eq 'marker' ) {
41 4         10 $self->{_default_marker} = { type => 'none' };
42             }
43              
44             # Override and reset the default axis values.
45 6         54 $self->{_x_axis}->{_defaults}->{major_gridlines} = { visible => 1 };
46 6         25 $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         16 $self->{_label_position_default} = 'center';
53 6         15 $self->{_label_positions} = { center => 'ctr' };
54              
55 6         15 bless $self, $class;
56              
57 6         24 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         28 $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   36 my $self = shift;
85 12         46 my %args = @_;
86              
87 12         18 my @series;
88 12 100       48 if ( $args{primary_axes} ) {
89 6         37 @series = $self->_get_primary_axes_series;
90             }
91             else {
92 6         43 @series = $self->_get_secondary_axes_series;
93             }
94              
95 12 100       38 return unless scalar @series;
96              
97 6         19 $self->xml_start_tag( 'c:radarChart' );
98              
99             # Write the c:radarStyle element.
100 6         19 $self->_write_radar_style();
101              
102             # Write the series elements.
103 6         40 $self->_write_series( $_ ) for @series;
104              
105             # Write the c:axId elements
106 6         78 $self->_write_axis_ids( %args );
107              
108 6         19 $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   11 my $self = shift;
121 6         10 my $val = 'marker';
122              
123 6 100       74 if ( $self->{_subtype} eq 'filled' ) {
124 1         9 $val = 'filled';
125             }
126              
127 6         17 my @attributes = ( 'val' => $val );
128              
129 6         20 $self->xml_empty_tag( 'c:radarStyle', @attributes );
130             }
131              
132              
133             1;
134              
135              
136             __END__