line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Writer::XLSX::Chart::Stock; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Stock - A class for writing Excel Stock 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
|
13
|
|
|
13
|
|
2487
|
use 5.008002; |
|
13
|
|
|
|
|
44
|
|
19
|
13
|
|
|
13
|
|
59
|
use strict; |
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
230
|
|
20
|
13
|
|
|
13
|
|
52
|
use warnings; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
282
|
|
21
|
13
|
|
|
13
|
|
56
|
use Carp; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
696
|
|
22
|
13
|
|
|
13
|
|
68
|
use Excel::Writer::XLSX::Chart; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
6501
|
|
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
|
13
|
|
|
13
|
0
|
709
|
my $class = shift; |
36
|
13
|
|
|
|
|
54
|
my $self = Excel::Writer::XLSX::Chart->new( @_ ); |
37
|
13
|
|
|
|
|
26
|
$self->{_show_crosses} = 0; |
38
|
13
|
|
|
|
|
26
|
$self->{_hi_low_lines} = {}; |
39
|
13
|
|
|
|
|
22
|
$self->{_date_category} = 1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Override and reset the default axis values. |
42
|
13
|
|
|
|
|
30
|
$self->{_x_axis}->{_defaults}->{num_format} = 'dd/mm/yyyy'; |
43
|
13
|
|
|
|
|
34
|
$self->{_x2_axis}->{_defaults}->{num_format} = 'dd/mm/yyyy'; |
44
|
13
|
|
|
|
|
47
|
$self->set_x_axis(); |
45
|
13
|
|
|
|
|
49
|
$self->set_x2_axis(); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Set the available data label positions for this chart type. |
48
|
13
|
|
|
|
|
23
|
$self->{_label_position_default} = 'right'; |
49
|
|
|
|
|
|
|
$self->{_label_positions} = { |
50
|
13
|
|
|
|
|
77
|
center => 'ctr', |
51
|
|
|
|
|
|
|
right => 'r', |
52
|
|
|
|
|
|
|
left => 'l', |
53
|
|
|
|
|
|
|
above => 't', |
54
|
|
|
|
|
|
|
below => 'b', |
55
|
|
|
|
|
|
|
# For backward compatibility. |
56
|
|
|
|
|
|
|
top => 't', |
57
|
|
|
|
|
|
|
bottom => 'b', |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
13
|
|
|
|
|
30
|
bless $self, $class; |
61
|
13
|
|
|
|
|
44
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
############################################################################## |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
# _write_chart_type() |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# Override the virtual superclass method with a chart specific method. |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
sub _write_chart_type { |
72
|
|
|
|
|
|
|
|
73
|
24
|
|
|
24
|
|
43
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Write the c:stockChart element. |
76
|
24
|
|
|
|
|
76
|
$self->_write_stock_chart( @_ ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
############################################################################## |
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
# _write_stock_chart() |
83
|
|
|
|
|
|
|
# |
84
|
|
|
|
|
|
|
# Write the element. |
85
|
|
|
|
|
|
|
# Overridden to add hi_low_lines(). TODO. Refactor up into the SUPER class. |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
sub _write_stock_chart { |
88
|
|
|
|
|
|
|
|
89
|
24
|
|
|
24
|
|
36
|
my $self = shift; |
90
|
24
|
|
|
|
|
62
|
my %args = @_; |
91
|
|
|
|
|
|
|
|
92
|
24
|
|
|
|
|
56
|
my @series; |
93
|
24
|
100
|
|
|
|
73
|
if ( $args{primary_axes} ) { |
94
|
12
|
|
|
|
|
91
|
@series = $self->_get_primary_axes_series; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
else { |
97
|
12
|
|
|
|
|
116
|
@series = $self->_get_secondary_axes_series; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
24
|
100
|
|
|
|
88
|
return unless scalar @series; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Add default formatting to the series data. |
103
|
13
|
|
|
|
|
66
|
$self->_modify_series_formatting(); |
104
|
|
|
|
|
|
|
|
105
|
13
|
|
|
|
|
49
|
$self->xml_start_tag( 'c:stockChart' ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Write the series elements. |
108
|
13
|
|
|
|
|
106
|
$self->_write_ser( $_ ) for @series; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Write the c:dropLines element. |
111
|
13
|
|
|
|
|
102
|
$self->_write_drop_lines(); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Write the c:hiLowLines element. |
114
|
13
|
100
|
|
|
|
107
|
$self->_write_hi_low_lines() if $args{primary_axes}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Write the c:upDownBars element. |
117
|
13
|
|
|
|
|
116
|
$self->_write_up_down_bars(); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Write the c:axId elements |
120
|
13
|
|
|
|
|
145
|
$self->_write_axis_ids( %args ); |
121
|
|
|
|
|
|
|
|
122
|
13
|
|
|
|
|
44
|
$self->xml_end_tag( 'c:stockChart' ); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
############################################################################## |
127
|
|
|
|
|
|
|
# |
128
|
|
|
|
|
|
|
# _modify_series_formatting() |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# Add default formatting to the series data. |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
sub _modify_series_formatting { |
133
|
|
|
|
|
|
|
|
134
|
13
|
|
|
13
|
|
28
|
my $self = shift; |
135
|
|
|
|
|
|
|
|
136
|
13
|
|
|
|
|
21
|
my $index = 0; |
137
|
13
|
|
|
|
|
29
|
for my $series ( @{ $self->{_series} } ) { |
|
13
|
|
|
|
|
36
|
|
138
|
39
|
50
|
|
|
|
114
|
if ( $index % 4 != 3 ) { |
139
|
39
|
100
|
|
|
|
117
|
if ( !$series->{_line}->{_defined} ) { |
140
|
|
|
|
|
|
|
$series->{_line} = { |
141
|
36
|
|
|
|
|
173
|
width => 2.25, |
142
|
|
|
|
|
|
|
none => 1, |
143
|
|
|
|
|
|
|
_defined => 1, |
144
|
|
|
|
|
|
|
}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
39
|
100
|
|
|
|
113
|
if ( !$series->{_marker} ) { |
148
|
36
|
100
|
|
|
|
94
|
if ( $index % 4 == 2 ) { |
149
|
12
|
|
|
|
|
50
|
$series->{_marker} = { type => 'dot', size => 3 }; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
else { |
152
|
24
|
|
|
|
|
68
|
$series->{_marker} = { type => 'none' }; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
39
|
|
|
|
|
84
|
$index++; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__ |