Initial Commit
This commit is contained in:
194
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Area.pm
vendored
Normal file
194
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Area.pm
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Area;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Area - A writer class for Excel Area charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the AREA chart BIFF record. Defines a area chart type.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x101A; # Record identifier.
|
||||
my $length = 0x0002; # Number of bytes to follow.
|
||||
my $grbit = 0x0001; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Area - A writer class for Excel Area charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Area chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'area' );
|
||||
|
||||
# Configure the chart.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
my $data = [
|
||||
[ 'Category', 2, 3, 4, 5, 6, 7 ],
|
||||
[ 'Value', 1, 4, 5, 2, 1, 5 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $data );
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Area charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'area' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Area Chart Methods
|
||||
|
||||
There aren't currently any area chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_area.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Number', 'Sample 1', 'Sample 2' ];
|
||||
my $data = [
|
||||
[ 2, 3, 4, 5, 6, 7 ],
|
||||
[ 1, 4, 5, 2, 1, 5 ],
|
||||
[ 3, 6, 7, 5, 4, 3 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
$worksheet->write( 'A2', $data );
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'area', embedded => 1 );
|
||||
|
||||
# Configure the first series. (Sample 1)
|
||||
$chart->add_series(
|
||||
name => 'Sample 1',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Configure the second series. (Sample 2)
|
||||
$chart->add_series(
|
||||
name => 'Sample 2',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$C$2:$C$7',
|
||||
);
|
||||
|
||||
# Add a chart title and some axis labels.
|
||||
$chart->set_title ( name => 'Results of sample analysis' );
|
||||
$chart->set_x_axis( name => 'Test number' );
|
||||
$chart->set_y_axis( name => 'Sample length (cm)' );
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'D2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/area1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
228
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Bar.pm
vendored
Normal file
228
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Bar.pm
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Bar;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Bar - A writer class for Excel Bar charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
bless $self, $class;
|
||||
|
||||
# The axis positions are reversed for a bar chart so we change the config.
|
||||
my $c = $self->{_config};
|
||||
$c->{_x_axis_text} = [ 0x2D, 0x6D9, 0x5F, 0x1CC, 0x281, 0x0, 90 ];
|
||||
$c->{_x_axis_text_pos} = [ 2, 2, 0, 0, 0x17, 0x2A ];
|
||||
$c->{_y_axis_text} = [ 0x078A, 0x0DFC, 0x011D, 0x9C, 0x0081, 0x0000 ];
|
||||
$c->{_y_axis_text_pos} = [ 2, 2, 0, 0, 0x45, 0x17 ];
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the BAR chart BIFF record. Defines a bar or column chart type.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x1017; # Record identifier.
|
||||
my $length = 0x0006; # Number of bytes to follow.
|
||||
my $pcOverlap = 0x0000; # Space between bars.
|
||||
my $pcGap = 0x0096; # Space between cats.
|
||||
my $grbit = 0x0001; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = '';
|
||||
$data .= pack 'v', $pcOverlap;
|
||||
$data .= pack 'v', $pcGap;
|
||||
$data .= pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _set_embedded_config_data()
|
||||
#
|
||||
# Override some of the default configuration data for an embedded chart.
|
||||
#
|
||||
sub _set_embedded_config_data {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
# Set the parent configuration first.
|
||||
$self->SUPER::_set_embedded_config_data();
|
||||
|
||||
# The axis positions are reversed for a bar chart so we change the config.
|
||||
my $c = $self->{_config};
|
||||
$c->{_x_axis_text} = [ 0x57, 0x5BC, 0xB5, 0x214, 0x281, 0x0, 90 ];
|
||||
$c->{_x_axis_text_pos} = [ 2, 2, 0, 0, 0x17, 0x2A ];
|
||||
$c->{_y_axis_text} = [ 0x074A, 0x0C8F, 0x021F, 0x123, 0x81, 0x0000 ];
|
||||
$c->{_y_axis_text_pos} = [ 2, 2, 0, 0, 0x45, 0x17 ];
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Bar - A writer class for Excel Bar charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Bar chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'bar' );
|
||||
|
||||
# Configure the chart.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
my $data = [
|
||||
[ 'Category', 2, 3, 4, 5, 6, 7 ],
|
||||
[ 'Value', 1, 4, 5, 2, 1, 5 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $data );
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Bar charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'bar' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Bar Chart Methods
|
||||
|
||||
There aren't currently any bar chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_bar.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Number', 'Sample 1', 'Sample 2' ];
|
||||
my $data = [
|
||||
[ 2, 3, 4, 5, 6, 7 ],
|
||||
[ 1, 4, 5, 2, 1, 5 ],
|
||||
[ 3, 6, 7, 5, 4, 3 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
$worksheet->write( 'A2', $data );
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'bar', embedded => 1 );
|
||||
|
||||
# Configure the first series. (Sample 1)
|
||||
$chart->add_series(
|
||||
name => 'Sample 1',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Configure the second series. (Sample 2)
|
||||
$chart->add_series(
|
||||
name => 'Sample 2',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$C$2:$C$7',
|
||||
);
|
||||
|
||||
# Add a chart title and some axis labels.
|
||||
$chart->set_title ( name => 'Results of sample analysis' );
|
||||
$chart->set_x_axis( name => 'Test number' );
|
||||
$chart->set_y_axis( name => 'Sample length (cm)' );
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'D2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/bar1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
199
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Column.pm
vendored
Normal file
199
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Column.pm
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Column;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Column - A writer class for Excel Column charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the BAR chart BIFF record. Defines a bar or column chart type.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x1017; # Record identifier.
|
||||
my $length = 0x0006; # Number of bytes to follow.
|
||||
my $pcOverlap = 0x0000; # Space between bars.
|
||||
my $pcGap = 0x0096; # Space between cats.
|
||||
my $grbit = 0x0000; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = '';
|
||||
$data .= pack 'v', $pcOverlap;
|
||||
$data .= pack 'v', $pcGap;
|
||||
$data .= pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Column - A writer class for Excel Column charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Column chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'column' );
|
||||
|
||||
# Configure the chart.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
my $data = [
|
||||
[ 'Category', 2, 3, 4, 5, 6, 7 ],
|
||||
[ 'Value', 1, 4, 5, 2, 1, 5 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $data );
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Column charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'column' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Column Chart Methods
|
||||
|
||||
There aren't currently any column chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_column.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Number', 'Sample 1', 'Sample 2' ];
|
||||
my $data = [
|
||||
[ 2, 3, 4, 5, 6, 7 ],
|
||||
[ 1, 4, 5, 2, 1, 5 ],
|
||||
[ 3, 6, 7, 5, 4, 3 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
$worksheet->write( 'A2', $data );
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'column', embedded => 1 );
|
||||
|
||||
# Configure the first series. (Sample 1)
|
||||
$chart->add_series(
|
||||
name => 'Sample 1',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Configure the second series. (Sample 2)
|
||||
$chart->add_series(
|
||||
name => 'Sample 2',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$C$2:$C$7',
|
||||
);
|
||||
|
||||
# Add a chart title and some axis labels.
|
||||
$chart->set_title ( name => 'Results of sample analysis' );
|
||||
$chart->set_x_axis( name => 'Test number' );
|
||||
$chart->set_y_axis( name => 'Sample length (cm)' );
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'D2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/column1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
119
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/External.pm
vendored
Normal file
119
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/External.pm
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
package Spreadsheet::WriteExcel::Chart::External;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# External - A writer class for Excel external charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel
|
||||
#
|
||||
# perltidy with options: -mbl=2 -pt=0 -nola
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $external_filename = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
$self->{_filename} = $external_filename;
|
||||
$self->{_external_bin} = 1;
|
||||
|
||||
bless $self, $class;
|
||||
$self->_initialize(); # Requires overridden initialize().
|
||||
return $self;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _initialize()
|
||||
#
|
||||
# Read all the data into memory for the external binary style chart.
|
||||
#
|
||||
#
|
||||
sub _initialize {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $filename = $self->{_filename};
|
||||
my $filehandle = FileHandle->new( $filename )
|
||||
or die "Couldn't open $filename in add_chart_ext(): $!.\n";
|
||||
|
||||
binmode( $filehandle );
|
||||
|
||||
$self->{_filehandle} = $filehandle;
|
||||
$self->{_datasize} = -s $filehandle;
|
||||
$self->{_using_tmpfile} = 0;
|
||||
|
||||
# Read the entire external chart binary into the data buffer.
|
||||
# This will be retrieved by _get_data() when the chart is closed().
|
||||
read( $self->{_filehandle}, $self->{_data}, $self->{_datasize} );
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _close()
|
||||
#
|
||||
# We don't need to create or store Chart data structures when using an
|
||||
# external binary, so we have a default close method.
|
||||
#
|
||||
sub _close {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
External - A writer class for Excel external charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
This module is used to include external charts in Spreadsheet::WriteExcel.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module is used to include external charts in L<Spreadsheet::WriteExcel>. It is an internal module and isn't used directly by the end user.
|
||||
|
||||
It is semi-deprecated in favour of using "native" charts. See L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
For information on how to used external charts see the C<external_charts.txt> (or C<.pod>) in the C<external_charts> directory of the distro.
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
194
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Line.pm
vendored
Normal file
194
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Line.pm
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Line;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Line - A writer class for Excel Line charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the LINE chart BIFF record. Defines a line chart type.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x1018; # Record identifier.
|
||||
my $length = 0x0002; # Number of bytes to follow.
|
||||
my $grbit = 0x0000; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Line - A writer class for Excel Line charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Line chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'line' );
|
||||
|
||||
# Configure the chart.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
my $data = [
|
||||
[ 'Category', 2, 3, 4, 5, 6, 7 ],
|
||||
[ 'Value', 1, 4, 5, 2, 1, 5 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $data );
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Line charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'line' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Line Chart Methods
|
||||
|
||||
There aren't currently any line chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_line.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Number', 'Sample 1', 'Sample 2' ];
|
||||
my $data = [
|
||||
[ 2, 3, 4, 5, 6, 7 ],
|
||||
[ 1, 4, 5, 2, 1, 5 ],
|
||||
[ 3, 6, 7, 5, 4, 3 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
$worksheet->write( 'A2', $data );
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'line', embedded => 1 );
|
||||
|
||||
# Configure the first series. (Sample 1)
|
||||
$chart->add_series(
|
||||
name => 'Sample 1',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Configure the second series. (Sample 2)
|
||||
$chart->add_series(
|
||||
name => 'Sample 2',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$C$2:$C$7',
|
||||
);
|
||||
|
||||
# Add a chart title and some axis labels.
|
||||
$chart->set_title ( name => 'Results of sample analysis' );
|
||||
$chart->set_x_axis( name => 'Test number' );
|
||||
$chart->set_y_axis( name => 'Sample length (cm)' );
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'D2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/line1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
217
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Pie.pm
vendored
Normal file
217
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Pie.pm
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Pie;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Pie - A writer class for Excel Pie charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
$self->{_vary_data_color} = 1;
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the Pie chart BIFF record.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x1019; # Record identifier.
|
||||
my $length = 0x0006; # Number of bytes to follow.
|
||||
my $angle = 0x0000; # Angle.
|
||||
my $donut = 0x0000; # Donut hole size.
|
||||
my $grbit = 0x0002; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = '';
|
||||
$data .= pack 'v', $angle;
|
||||
$data .= pack 'v', $donut;
|
||||
$data .= pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_axisparent_stream(). Overridden.
|
||||
#
|
||||
# Write the AXISPARENT chart substream.
|
||||
#
|
||||
# A Pie chart has no X or Y axis so we override this method to remove them.
|
||||
#
|
||||
sub _store_axisparent_stream {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
$self->_store_axisparent( @{ $self->{_config}->{_axisparent} } );
|
||||
|
||||
$self->_store_begin();
|
||||
$self->_store_pos( @{ $self->{_config}->{_axisparent_pos} } );
|
||||
|
||||
$self->_store_chartformat_stream();
|
||||
$self->_store_end();
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Pie - A writer class for Excel Pie charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Pie chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'pie' );
|
||||
|
||||
# Configure the chart.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
my $data = [
|
||||
[ 'Category', 2, 3, 4, 5, 6, 7 ],
|
||||
[ 'Value', 1, 4, 5, 2, 1, 5 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $data );
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Pie charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'pie' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Pie Chart Methods
|
||||
|
||||
There aren't currently any pie chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
A Pie chart doesn't have an X or Y axis so the following common chart methods are ignored.
|
||||
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_pie.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Category', 'Values' ];
|
||||
my $data = [
|
||||
[ 'Apple', 'Cherry', 'Pecan' ],
|
||||
[ 60, 30, 10 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
$worksheet->write( 'A2', $data );
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'pie', embedded => 1 );
|
||||
|
||||
# Configure the series.
|
||||
$chart->add_series(
|
||||
name => 'Pie sales data',
|
||||
categories => '=Sheet1!$A$2:$A$4',
|
||||
values => '=Sheet1!$B$2:$B$4',
|
||||
);
|
||||
|
||||
# Add a title.
|
||||
$chart->set_title( name => 'Popular Pie Types' );
|
||||
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'C2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/pie1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
245
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Scatter.pm
vendored
Normal file
245
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Scatter.pm
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Scatter;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Scatter - A writer class for Excel Scatter charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the SCATTER chart BIFF record. Defines a scatter chart type.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x101B; # Record identifier.
|
||||
my $length = 0x0006; # Number of bytes to follow.
|
||||
my $bubble_ratio = 0x0064; # Bubble ratio.
|
||||
my $bubble_type = 0x0001; # Bubble type.
|
||||
my $grbit = 0x0000; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = '';
|
||||
$data .= pack 'v', $bubble_ratio;
|
||||
$data .= pack 'v', $bubble_type;
|
||||
$data .= pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_axis_category_stream(). Overridden.
|
||||
#
|
||||
# Write the AXIS chart substream for the chart category.
|
||||
#
|
||||
# For a Scatter chart the category stream is replace with a values stream. We
|
||||
# override this method and turn it into a values stream.
|
||||
#
|
||||
sub _store_axis_category_stream {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
$self->_store_axis( 0 );
|
||||
|
||||
$self->_store_begin();
|
||||
$self->_store_valuerange();
|
||||
$self->_store_tick();
|
||||
$self->_store_end();
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_marker_dataformat_stream(). Overridden.
|
||||
#
|
||||
# This is an implementation of the parent abstract method to define
|
||||
# properties of markers, linetypes, pie formats and other.
|
||||
#
|
||||
sub _store_marker_dataformat_stream {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
$self->_store_dataformat( 0x0000, 0xFFFD, 0x0000 );
|
||||
|
||||
$self->_store_begin();
|
||||
$self->_store_3dbarshape();
|
||||
$self->_store_lineformat( 0x00000000, 0x0005, 0xFFFF, 0x0008, 0x004D );
|
||||
$self->_store_areaformat( 0x00FFFFFF, 0x0000, 0x01, 0x01, 0x4E, 0x4D );
|
||||
$self->_store_pieformat();
|
||||
$self->_store_markerformat( 0x00, 0x00, 0x02, 0x01, 0x4D, 0x4D, 0x3C );
|
||||
$self->_store_end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Scatter - A writer class for Excel Scatter charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Scatter chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'scatter' );
|
||||
|
||||
# Configure the chart.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
my $data = [
|
||||
[ 'Category', 2, 3, 4, 5, 6, 7 ],
|
||||
[ 'Value', 1, 4, 5, 2, 1, 5 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $data );
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Scatter charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'scatter' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Scatter Chart Methods
|
||||
|
||||
There aren't currently any scatter chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_scatter.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Number', 'Sample 1', 'Sample 2' ];
|
||||
my $data = [
|
||||
[ 2, 3, 4, 5, 6, 7 ],
|
||||
[ 1, 4, 5, 2, 1, 5 ],
|
||||
[ 3, 6, 7, 5, 4, 3 ],
|
||||
];
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
$worksheet->write( 'A2', $data );
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'scatter', embedded => 1 );
|
||||
|
||||
# Configure the first series. (Sample 1)
|
||||
$chart->add_series(
|
||||
name => 'Sample 1',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$B$2:$B$7',
|
||||
);
|
||||
|
||||
# Configure the second series. (Sample 2)
|
||||
$chart->add_series(
|
||||
name => 'Sample 2',
|
||||
categories => '=Sheet1!$A$2:$A$7',
|
||||
values => '=Sheet1!$C$2:$C$7',
|
||||
);
|
||||
|
||||
# Add a chart title and some axis labels.
|
||||
$chart->set_title ( name => 'Results of sample analysis' );
|
||||
$chart->set_x_axis( name => 'Test number' );
|
||||
$chart->set_y_axis( name => 'Sample length (cm)' );
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'D2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/scatter1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
257
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Stock.pm
vendored
Normal file
257
database/perl/vendor/lib/Spreadsheet/WriteExcel/Chart/Stock.pm
vendored
Normal file
@@ -0,0 +1,257 @@
|
||||
package Spreadsheet::WriteExcel::Chart::Stock;
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Stock - A writer class for Excel Stock charts.
|
||||
#
|
||||
# Used in conjunction with Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# See formatting note in Spreadsheet::WriteExcel::Chart.
|
||||
#
|
||||
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
# Documentation after __END__
|
||||
#
|
||||
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel::Chart;
|
||||
|
||||
|
||||
use vars qw($VERSION @ISA);
|
||||
@ISA = qw(Spreadsheet::WriteExcel::Chart Exporter);
|
||||
|
||||
$VERSION = '2.40';
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# new()
|
||||
#
|
||||
#
|
||||
sub new {
|
||||
|
||||
my $class = shift;
|
||||
my $self = Spreadsheet::WriteExcel::Chart->new( @_ );
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_chart_type()
|
||||
#
|
||||
# Implementation of the abstract method from the specific chart class.
|
||||
#
|
||||
# Write the LINE chart BIFF record. A stock chart uses the same LINE record
|
||||
# as a line chart but with additional DROPBAR and CHARTLINE records to define
|
||||
# the stock style.
|
||||
#
|
||||
sub _store_chart_type {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
my $record = 0x1018; # Record identifier.
|
||||
my $length = 0x0002; # Number of bytes to follow.
|
||||
my $grbit = 0x0000; # Option flags.
|
||||
|
||||
my $header = pack 'vv', $record, $length;
|
||||
my $data = pack 'v', $grbit;
|
||||
|
||||
$self->_append( $header, $data );
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# _store_marker_dataformat_stream(). Overridden.
|
||||
#
|
||||
# This is an implementation of the parent abstract method to define
|
||||
# properties of markers, linetypes, pie formats and other.
|
||||
#
|
||||
sub _store_marker_dataformat_stream {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
$self->_store_dropbar();
|
||||
$self->_store_begin();
|
||||
$self->_store_lineformat( 0x00000000, 0x0000, 0xFFFF, 0x0001, 0x004F );
|
||||
$self->_store_areaformat( 0x00FFFFFF, 0x0000, 0x01, 0x01, 0x09, 0x08 );
|
||||
$self->_store_end();
|
||||
|
||||
$self->_store_dropbar();
|
||||
$self->_store_begin();
|
||||
$self->_store_lineformat( 0x00000000, 0x0000, 0xFFFF, 0x0001, 0x004F );
|
||||
$self->_store_areaformat( 0x0000, 0x00FFFFFF, 0x01, 0x01, 0x08, 0x09 );
|
||||
$self->_store_end();
|
||||
|
||||
$self->_store_chartline();
|
||||
$self->_store_lineformat( 0x00000000, 0x0000, 0xFFFF, 0x0000, 0x004F );
|
||||
|
||||
|
||||
$self->_store_dataformat( 0x0000, 0xFFFD, 0x0000 );
|
||||
$self->_store_begin();
|
||||
$self->_store_3dbarshape();
|
||||
$self->_store_lineformat( 0x00000000, 0x0005, 0xFFFF, 0x0000, 0x004F );
|
||||
$self->_store_areaformat( 0x00000000, 0x0000, 0x00, 0x01, 0x4D, 0x4D );
|
||||
$self->_store_pieformat();
|
||||
$self->_store_markerformat( 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4D, 0x3C );
|
||||
$self->_store_end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Stock - A writer class for Excel Stock charts.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
To create a simple Excel file with a Stock chart using Spreadsheet::WriteExcel:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'stock' );
|
||||
|
||||
# Add a series for each Open-High-Low-Close.
|
||||
$chart->add_series( categories => '=Sheet1!$A$2:$A$6', values => '=Sheet1!$B$2:$B$6' );
|
||||
$chart->add_series( categories => '=Sheet1!$A$2:$A$6', values => '=Sheet1!$C$2:$C$6' );
|
||||
$chart->add_series( categories => '=Sheet1!$A$2:$A$6', values => '=Sheet1!$D$2:$D$6' );
|
||||
$chart->add_series( categories => '=Sheet1!$A$2:$A$6', values => '=Sheet1!$E$2:$E$6' );
|
||||
|
||||
# Add the worksheet data the chart refers to.
|
||||
# ... See the full example below.
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module implements Stock charts for L<Spreadsheet::WriteExcel>. The chart object is created via the Workbook C<add_chart()> method:
|
||||
|
||||
my $chart = $workbook->add_chart( type => 'stock' );
|
||||
|
||||
Once the object is created it can be configured via the following methods that are common to all chart classes:
|
||||
|
||||
$chart->add_series();
|
||||
$chart->set_x_axis();
|
||||
$chart->set_y_axis();
|
||||
$chart->set_title();
|
||||
|
||||
These methods are explained in detail in L<Spreadsheet::WriteExcel::Chart>. Class specific methods or settings, if any, are explained below.
|
||||
|
||||
=head1 Stock Chart Methods
|
||||
|
||||
There aren't currently any stock chart specific methods. See the TODO section of L<Spreadsheet::WriteExcel::Chart>.
|
||||
|
||||
The default Stock chart is an Open-High-Low-Close chart. A series must be added for each of these data sources.
|
||||
|
||||
The default Stock chart is in black and white. User defined colours will be added at a later stage.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Here is a complete example that demonstrates most of the available features when creating a Stock chart.
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use Spreadsheet::WriteExcel;
|
||||
|
||||
my $workbook = Spreadsheet::WriteExcel->new( 'chart_stock_ex.xls' );
|
||||
my $worksheet = $workbook->add_worksheet();
|
||||
my $bold = $workbook->add_format( bold => 1 );
|
||||
my $date_format = $workbook->add_format( num_format => 'dd/mm/yyyy' );
|
||||
|
||||
# Add the worksheet data that the charts will refer to.
|
||||
my $headings = [ 'Date', 'Open', 'High', 'Low', 'Close' ];
|
||||
my @data = (
|
||||
[ '2009-08-23', 110.75, 113.48, 109.05, 109.40 ],
|
||||
[ '2009-08-24', 111.24, 111.60, 103.57, 104.87 ],
|
||||
[ '2009-08-25', 104.96, 108.00, 103.88, 106.00 ],
|
||||
[ '2009-08-26', 104.95, 107.95, 104.66, 107.91 ],
|
||||
[ '2009-08-27', 108.10, 108.62, 105.69, 106.15 ],
|
||||
);
|
||||
|
||||
$worksheet->write( 'A1', $headings, $bold );
|
||||
|
||||
my $row = 1;
|
||||
for my $data ( @data ) {
|
||||
$worksheet->write( $row, 0, $data->[0], $date_format );
|
||||
$worksheet->write( $row, 1, $data->[1] );
|
||||
$worksheet->write( $row, 2, $data->[2] );
|
||||
$worksheet->write( $row, 3, $data->[3] );
|
||||
$worksheet->write( $row, 4, $data->[4] );
|
||||
$row++;
|
||||
}
|
||||
|
||||
# Create a new chart object. In this case an embedded chart.
|
||||
my $chart = $workbook->add_chart( type => 'stock', embedded => 1 );
|
||||
|
||||
# Add a series for each of the Open-High-Low-Close columns.
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$6',
|
||||
values => '=Sheet1!$B$2:$B$6',
|
||||
name => 'Open',
|
||||
);
|
||||
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$6',
|
||||
values => '=Sheet1!$C$2:$C$6',
|
||||
name => 'High',
|
||||
);
|
||||
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$6',
|
||||
values => '=Sheet1!$D$2:$D$6',
|
||||
name => 'Low',
|
||||
);
|
||||
|
||||
$chart->add_series(
|
||||
categories => '=Sheet1!$A$2:$A$6',
|
||||
values => '=Sheet1!$E$2:$E$6',
|
||||
name => 'Close',
|
||||
);
|
||||
|
||||
# Add a chart title and some axis labels.
|
||||
$chart->set_title( name => 'Open-High-Low-Close', );
|
||||
$chart->set_x_axis( name => 'Date', );
|
||||
$chart->set_y_axis( name => 'Share price', );
|
||||
|
||||
# Insert the chart into the worksheet (with an offset).
|
||||
$worksheet->insert_chart( 'F2', $chart, 25, 10 );
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
=begin html
|
||||
|
||||
<p>This will produce a chart that looks like this:</p>
|
||||
|
||||
<p><center><img src="http://homepage.eircom.net/~jmcnamara/perl/images/stock1.jpg" width="527" height="320" alt="Chart example." /></center></p>
|
||||
|
||||
=end html
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
John McNamara jmcnamara@cpan.org
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright MM-MMX, John McNamara.
|
||||
|
||||
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
||||
|
||||
Reference in New Issue
Block a user