line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Writer::XLSX::Chart::Bar; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Bar - A class for writing Excel Bar 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
|
62
|
|
|
62
|
|
8029
|
use 5.008002; |
|
62
|
|
|
|
|
231
|
|
19
|
62
|
|
|
62
|
|
299
|
use strict; |
|
62
|
|
|
|
|
109
|
|
|
62
|
|
|
|
|
1156
|
|
20
|
62
|
|
|
62
|
|
262
|
use warnings; |
|
62
|
|
|
|
|
100
|
|
|
62
|
|
|
|
|
1399
|
|
21
|
62
|
|
|
62
|
|
272
|
use Carp; |
|
62
|
|
|
|
|
103
|
|
|
62
|
|
|
|
|
3420
|
|
22
|
62
|
|
|
62
|
|
370
|
use Excel::Writer::XLSX::Chart; |
|
62
|
|
|
|
|
143
|
|
|
62
|
|
|
|
|
40991
|
|
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
|
68
|
|
|
68
|
0
|
2287
|
my $class = shift; |
36
|
68
|
|
|
|
|
287
|
my $self = Excel::Writer::XLSX::Chart->new( @_ ); |
37
|
|
|
|
|
|
|
|
38
|
68
|
|
100
|
|
|
341
|
$self->{_subtype} = $self->{_subtype} || 'clustered'; |
39
|
68
|
|
|
|
|
145
|
$self->{_cat_axis_position} = 'l'; |
40
|
68
|
|
|
|
|
142
|
$self->{_val_axis_position} = 'b'; |
41
|
68
|
|
|
|
|
133
|
$self->{_horiz_val_axis} = 0; |
42
|
68
|
|
|
|
|
147
|
$self->{_horiz_cat_axis} = 1; |
43
|
68
|
|
|
|
|
138
|
$self->{_show_crosses} = 0; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Override and reset the default axis values. |
46
|
68
|
|
|
|
|
254
|
$self->{_x_axis}->{_defaults}->{major_gridlines} = { visible => 1 }; |
47
|
68
|
|
|
|
|
217
|
$self->{_y_axis}->{_defaults}->{major_gridlines} = { visible => 0 }; |
48
|
|
|
|
|
|
|
|
49
|
68
|
100
|
|
|
|
285
|
if ( $self->{_subtype} eq 'percent_stacked' ) { |
50
|
1
|
|
|
|
|
2
|
$self->{_x_axis}->{_defaults}->{num_format} = '0%'; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
68
|
|
|
|
|
333
|
$self->set_x_axis(); |
54
|
68
|
|
|
|
|
265
|
$self->set_y_axis(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Set the available data label positions for this chart type. |
57
|
68
|
|
|
|
|
131
|
$self->{_label_position_default} = 'outside_end'; |
58
|
|
|
|
|
|
|
$self->{_label_positions} = { |
59
|
68
|
|
|
|
|
277
|
center => 'ctr', |
60
|
|
|
|
|
|
|
inside_base => 'inBase', |
61
|
|
|
|
|
|
|
inside_end => 'inEnd', |
62
|
|
|
|
|
|
|
outside_end => 'outEnd', |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
68
|
|
|
|
|
167
|
bless $self, $class; |
66
|
68
|
|
|
|
|
225
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
############################################################################### |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
# combine() |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# Override parent method to add an extra check that is required for Bar |
75
|
|
|
|
|
|
|
# charts to ensure that their combined chart is on a secondary axis. |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
sub combine { |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
80
|
1
|
|
|
|
|
1
|
my $chart = shift; |
81
|
|
|
|
|
|
|
|
82
|
1
|
50
|
|
|
|
3
|
if (!$chart->{_is_secondary}) { |
83
|
0
|
|
|
|
|
0
|
carp 'Charts combined with Bar charts must be on a secondary axis'; |
84
|
0
|
|
|
|
|
0
|
return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
2
|
$self->{_combined} = $chart; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
############################################################################## |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# _write_chart_type() |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# Override the virtual superclass method with a chart specific method. |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
sub _write_chart_type { |
98
|
|
|
|
|
|
|
|
99
|
130
|
|
|
130
|
|
247
|
my $self = shift; |
100
|
130
|
|
|
|
|
376
|
my %args = @_; |
101
|
|
|
|
|
|
|
|
102
|
130
|
100
|
|
|
|
398
|
if ( $args{primary_axes} ) { |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Reverse X and Y axes for Bar charts. |
105
|
65
|
|
|
|
|
247
|
my $tmp = $self->{_y_axis}; |
106
|
65
|
|
|
|
|
175
|
$self->{_y_axis} = $self->{_x_axis}; |
107
|
65
|
|
|
|
|
150
|
$self->{_x_axis} = $tmp; |
108
|
|
|
|
|
|
|
|
109
|
65
|
50
|
|
|
|
320
|
if ( $self->{_y2_axis}->{_position} eq 'r' ) { |
110
|
65
|
|
|
|
|
205
|
$self->{_y2_axis}->{_position} = 't'; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Write the c:barChart element. |
115
|
130
|
|
|
|
|
431
|
$self->_write_bar_chart( @_ ); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
############################################################################## |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
# _write_bar_chart() |
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
# Write the element. |
124
|
|
|
|
|
|
|
# |
125
|
|
|
|
|
|
|
sub _write_bar_chart { |
126
|
|
|
|
|
|
|
|
127
|
130
|
|
|
130
|
|
227
|
my $self = shift; |
128
|
130
|
|
|
|
|
272
|
my %args = @_; |
129
|
|
|
|
|
|
|
|
130
|
130
|
|
|
|
|
230
|
my @series; |
131
|
130
|
100
|
|
|
|
382
|
if ( $args{primary_axes} ) { |
132
|
65
|
|
|
|
|
536
|
@series = $self->_get_primary_axes_series; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else { |
135
|
65
|
|
|
|
|
493
|
@series = $self->_get_secondary_axes_series; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
130
|
100
|
|
|
|
444
|
return unless scalar @series; |
139
|
|
|
|
|
|
|
|
140
|
67
|
|
|
|
|
211
|
my $subtype = $self->{_subtype}; |
141
|
67
|
100
|
|
|
|
245
|
$subtype = 'percentStacked' if $subtype eq 'percent_stacked'; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Set a default overlap for stacked charts. |
144
|
67
|
100
|
|
|
|
326
|
if ($self->{_subtype} =~ /stacked/) { |
145
|
2
|
50
|
|
|
|
6
|
if (!defined $self->{_series_overlap_1}) { |
146
|
2
|
|
|
|
|
4
|
$self->{_series_overlap_1} = 100; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
67
|
|
|
|
|
292
|
$self->xml_start_tag( 'c:barChart' ); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Write the c:barDir element. |
153
|
67
|
|
|
|
|
278
|
$self->_write_bar_dir(); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Write the c:grouping element. |
156
|
67
|
|
|
|
|
506
|
$self->_write_grouping( $subtype ); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# Write the c:ser elements. |
159
|
67
|
|
|
|
|
524
|
$self->_write_ser( $_ ) for @series; |
160
|
|
|
|
|
|
|
|
161
|
67
|
100
|
|
|
|
368
|
if ( $args{primary_axes} ) { |
162
|
|
|
|
|
|
|
# Write the c:gapWidth element. |
163
|
65
|
|
|
|
|
697
|
$self->_write_gap_width( $self->{_series_gap_1} ); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# Write the c:overlap element. |
166
|
65
|
|
|
|
|
537
|
$self->_write_overlap( $self->{_series_overlap_1} ); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
else { |
169
|
|
|
|
|
|
|
# Write the c:gapWidth element. |
170
|
2
|
|
|
|
|
9
|
$self->_write_gap_width( $self->{_series_gap_2} ); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# Write the c:overlap element. |
173
|
2
|
|
|
|
|
8
|
$self->_write_overlap( $self->{_series_overlap_2} ); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# Write the c:axId elements |
177
|
67
|
|
|
|
|
754
|
$self->_write_axis_ids( %args ); |
178
|
|
|
|
|
|
|
|
179
|
67
|
|
|
|
|
252
|
$self->xml_end_tag( 'c:barChart' ); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
############################################################################## |
184
|
|
|
|
|
|
|
# |
185
|
|
|
|
|
|
|
# _write_bar_dir() |
186
|
|
|
|
|
|
|
# |
187
|
|
|
|
|
|
|
# Write the element. |
188
|
|
|
|
|
|
|
# |
189
|
|
|
|
|
|
|
sub _write_bar_dir { |
190
|
|
|
|
|
|
|
|
191
|
68
|
|
|
68
|
|
155
|
my $self = shift; |
192
|
68
|
|
|
|
|
155
|
my $val = 'bar'; |
193
|
|
|
|
|
|
|
|
194
|
68
|
|
|
|
|
205
|
my @attributes = ( 'val' => $val ); |
195
|
|
|
|
|
|
|
|
196
|
68
|
|
|
|
|
279
|
$self->xml_empty_tag( 'c:barDir', @attributes ); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
############################################################################## |
201
|
|
|
|
|
|
|
# |
202
|
|
|
|
|
|
|
# _write_err_dir() |
203
|
|
|
|
|
|
|
# |
204
|
|
|
|
|
|
|
# Write the element. Overridden from Chart class since it is not |
205
|
|
|
|
|
|
|
# used in Bar charts. |
206
|
|
|
|
|
|
|
# |
207
|
|
|
|
1
|
|
|
sub _write_err_dir {} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
1; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
__END__ |