File Coverage

blib/lib/Spreadsheet/WriteExcel/Chart/Bar.pm
Criterion Covered Total %
statement 30 37 81.0
branch n/a
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 35 44 79.5


line stmt bran cond sub pod time code
1             package Spreadsheet::WriteExcel::Chart::Bar;
2              
3             ###############################################################################
4             #
5             # Bar - A writer class for Excel Bar charts.
6             #
7             # Used in conjunction with Spreadsheet::WriteExcel::Chart.
8             #
9             # See formatting note in Spreadsheet::WriteExcel::Chart.
10             #
11             # Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
12             #
13             # Documentation after __END__
14             #
15              
16             require Exporter;
17              
18 1     1   88 use strict;
  1         2  
  1         38  
19 1     1   6 use Spreadsheet::WriteExcel::Chart;
  1         2  
  1         52  
20              
21              
22 1     1   6 use vars qw($VERSION @ISA);
  1         1  
  1         458  
23             @ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
24              
25             $VERSION = '2.40';
26              
27             ###############################################################################
28             #
29             # new()
30             #
31             #
32             sub new {
33              
34 1     1 0 3 my $class = shift;
35 1         5 my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
36              
37 1         3 bless $self, $class;
38              
39             # The axis positions are reversed for a bar chart so we change the config.
40 1         13 my $c = $self->{_config};
41 1         3 $c->{_x_axis_text} = [ 0x2D, 0x6D9, 0x5F, 0x1CC, 0x281, 0x0, 90 ];
42 1         4 $c->{_x_axis_text_pos} = [ 2, 2, 0, 0, 0x17, 0x2A ];
43 1         4 $c->{_y_axis_text} = [ 0x078A, 0x0DFC, 0x011D, 0x9C, 0x0081, 0x0000 ];
44 1         3 $c->{_y_axis_text_pos} = [ 2, 2, 0, 0, 0x45, 0x17 ];
45              
46 1         11 return $self;
47             }
48              
49              
50             ###############################################################################
51             #
52             # _store_chart_type()
53             #
54             # Implementation of the abstract method from the specific chart class.
55             #
56             # Write the BAR chart BIFF record. Defines a bar or column chart type.
57             #
58             sub _store_chart_type {
59              
60 1     1   163 my $self = shift;
61              
62 1         2 my $record = 0x1017; # Record identifier.
63 1         2 my $length = 0x0006; # Number of bytes to follow.
64 1         2 my $pcOverlap = 0x0000; # Space between bars.
65 1         1 my $pcGap = 0x0096; # Space between cats.
66 1         2 my $grbit = 0x0001; # Option flags.
67              
68 1         5 my $header = pack 'vv', $record, $length;
69 1         2 my $data = '';
70 1         2 $data .= pack 'v', $pcOverlap;
71 1         2 $data .= pack 'v', $pcGap;
72 1         3 $data .= pack 'v', $grbit;
73              
74 1         10 $self->_append( $header, $data );
75             }
76              
77             ###############################################################################
78             #
79             # _set_embedded_config_data()
80             #
81             # Override some of the default configuration data for an embedded chart.
82             #
83             sub _set_embedded_config_data {
84              
85 0     0     my $self = shift;
86              
87             # Set the parent configuration first.
88 0           $self->SUPER::_set_embedded_config_data();
89              
90             # The axis positions are reversed for a bar chart so we change the config.
91 0           my $c = $self->{_config};
92 0           $c->{_x_axis_text} = [ 0x57, 0x5BC, 0xB5, 0x214, 0x281, 0x0, 90 ];
93 0           $c->{_x_axis_text_pos} = [ 2, 2, 0, 0, 0x17, 0x2A ];
94 0           $c->{_y_axis_text} = [ 0x074A, 0x0C8F, 0x021F, 0x123, 0x81, 0x0000 ];
95 0           $c->{_y_axis_text_pos} = [ 2, 2, 0, 0, 0x45, 0x17 ];
96              
97             }
98              
99             1;
100              
101              
102             __END__