view release on metacpan or search on metacpan
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
# Set the pattern properties.
$title->{_pattern} = $self->_get_pattern_properties( $arg{pattern} );
# Set the gradient fill properties.
$title->{_gradient} = $self->_get_gradient_properties( $arg{gradient} );
# Set the title layout.
$title->{_layout} = $self->_get_layout_properties( $arg{layout}, 1 );
# Set the title overlay option.
$title->{_overlay} = $arg{overlay};
# Set the no automatic title option.
$title->{_none} = $arg{none};
# Copy the title to the main chart object.
$self->{_title} = $title;
}
###############################################################################
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
#
# Write the <c:legend> element.
#
sub _write_legend {
my $self = shift;
my $legend = $self->{_legend};
my $position = $legend->{_position} || 'right';
my $font = $legend->{_font};
my @delete_series = ();
my $overlay = 0;
if ( defined $legend->{_delete_series}
&& ref $legend->{_delete_series} eq 'ARRAY' )
{
@delete_series = @{ $legend->{_delete_series} };
}
if ( $position =~ s/^overlay_// ) {
$overlay = 1;
}
my %allowed = (
right => 'r',
left => 'l',
top => 't',
bottom => 'b',
top_right => 'tr',
);
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
# Remove series labels from the legend.
for my $index ( @delete_series ) {
# Write the c:legendEntry element.
$self->_write_legend_entry( $index );
}
# Write the c:layout element.
$self->_write_layout( $legend->{_layout}, 'legend' );
# Write the c:overlay element.
$self->_write_overlay() if $overlay;
# Write the c:spPr element.
$self->_write_sp_pr( $legend );
# Write the c:txPr element.
if ( $font ) {
$self->_write_tx_pr( $font );
}
$self->xml_end_tag( 'c:legend' );
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
# Write the c:delete element.
$self->_write_delete( 1 );
$self->xml_end_tag( 'c:legendEntry' );
}
##############################################################################
#
# _write_overlay()
#
# Write the <c:overlay> element.
#
sub _write_overlay {
my $self = shift;
my $val = 1;
my @attributes = ( 'val' => $val );
$self->xml_empty_tag( 'c:overlay', @attributes );
}
##############################################################################
#
# _write_plot_vis_only()
#
# Write the <c:plotVisOnly> element.
#
sub _write_plot_vis_only {
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
my $is_y_axis = shift;
$self->xml_start_tag( 'c:title' );
# Write the c:tx element.
$self->_write_tx_rich( $title->{_name}, $is_y_axis, $title->{_font} );
# Write the c:layout element.
$self->_write_layout( $title->{_layout}, 'text' );
# Write the c:overlay element.
$self->_write_overlay() if $title->{_overlay};
# Write the c:spPr element.
$self->_write_sp_pr( $title );
$self->xml_end_tag( 'c:title' );
}
##############################################################################
#
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
my $is_y_axis = shift;
$self->xml_start_tag( 'c:title' );
# Write the c:tx element.
$self->_write_tx_formula( $title->{_formula}, $title->{_data_id} );
# Write the c:layout element.
$self->_write_layout( $title->{_layout}, 'text' );
# Write the c:overlay element.
$self->_write_overlay() if $title->{_overlay};
# Write the c:spPr element.
$self->_write_sp_pr( $title );
# Write the c:txPr element.
$self->_write_tx_pr( $title->{_font}, $is_y_axis );
$self->xml_end_tag( 'c:title' );
}
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
sub _write_title_format_only {
my $self = shift;
my $title = shift;
$self->xml_start_tag( 'c:title' );
# Write the c:layout element.
$self->_write_layout( $title->{_layout}, 'text' );
# Write the c:overlay element.
$self->_write_overlay() if $title->{_overlay};
# Write the c:spPr element.
$self->_write_sp_pr( $title );
$self->xml_end_tag( 'c:title' );
}
##############################################################################
#
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
Set the fill properties of the legend such as colour. See the L</CHART FORMATTING> section below.
=item * C<pattern>
Set the pattern fill properties of the legend. See the L</CHART FORMATTING> section below.
=item * C<gradient>
Set the gradient fill properties of the legend. See the L</CHART FORMATTING> section below.
=item * C<overlay>
Allow the title to be overlaid on the chart. Generally used with the layout property below.
=item * C<layout>
Set the C<(x, y)> position of the title in chart relative units:
$chart->set_title(
name => 'Title',
overlay => 1,
layout => {
x => 0.42,
y => 0.14,
}
);
See the L</CHART LAYOUT> section below.
=item * C<none>
lib/Excel/Writer/XLSX/Chart.pm view on Meta::CPAN
$chart->set_legend( position => 'bottom' );
The default legend position is C<right>. The available positions are:
top
bottom
left
right
top_right
overlay_left
overlay_right
overlay_top_right
none
=item * C<border>
Set the border properties of the legend such as colour and style. See the L</CHART FORMATTING> section below.
=item * C<fill>
Set the fill properties of the legend such as colour. See the L</CHART FORMATTING> section below.
lib/Excel/Writer/XLSX/Chart/Pie.pm view on Meta::CPAN
#
# Write the <c:legend> element.
#
sub _write_legend {
my $self = shift;
my $legend = $self->{_legend};
my $position = $legend->{_position} || 'right';
my $font = $legend->{_font};
my @delete_series = ();
my $overlay = 0;
if ( defined $legend->{_delete_series}
&& ref $legend->{_delete_series} eq 'ARRAY' )
{
@delete_series = @{ $legend->{_delete_series} };
}
if ( $position =~ s/^overlay_// ) {
$overlay = 1;
}
my %allowed = (
right => 'r',
left => 'l',
top => 't',
bottom => 'b',
top_right => 'tr',
);
lib/Excel/Writer/XLSX/Chart/Pie.pm view on Meta::CPAN
# Remove series labels from the legend.
for my $index ( @delete_series ) {
# Write the c:legendEntry element.
$self->_write_legend_entry( $index );
}
# Write the c:layout element.
$self->_write_layout( $legend->{_layout}, 'legend' );
# Write the c:overlay element.
$self->_write_overlay() if $overlay;
# Write the c:spPr element.
$self->_write_sp_pr( $legend );
# Write the c:txPr element. Over-ridden.
$self->_write_tx_pr_legend( 0, $font );
$self->xml_end_tag( 'c:legend' );
}
t/chart/sub_write_legend.t view on Meta::CPAN
$chart->_write_legend();
is( $got, $expected, $caption );
###############################################################################
#
# Test the _write_legend() method.
#
$caption = " \tChart: _write_legend()";
$expected = '<c:legend><c:legendPos val="r"/><c:layout/><c:overlay val="1"/></c:legend>';
$chart = _new_object( \$got, 'Excel::Writer::XLSX::Chart' );
$chart->set_legend( position => 'overlay_right' );
$chart->_write_legend();
is( $got, $expected, $caption );
###############################################################################
#
# Test the _write_legend() method.
#
$caption = " \tChart: _write_legend()";
$expected = '<c:legend><c:legendPos val="l"/><c:layout/><c:overlay val="1"/></c:legend>';
$chart = _new_object( \$got, 'Excel::Writer::XLSX::Chart' );
$chart->set_legend( position => 'overlay_left' );
$chart->_write_legend();
is( $got, $expected, $caption );
###############################################################################
#
# Test the _write_legend() method.
#
$caption = " \tChart: _write_legend()";
t/chart/sub_write_legend.t view on Meta::CPAN
$chart->_write_legend();
is( $got, $expected, $caption );
###############################################################################
#
# Test the _write_legend() method.
#
$caption = " \tChart: _write_legend()";
$expected = '<c:legend><c:legendPos val="tr"/><c:layout/><c:overlay val="1"/></c:legend>';
$chart = _new_object( \$got, 'Excel::Writer::XLSX::Chart' );
$chart->set_legend( position => 'overlay_top_right' );
$chart->_write_legend();
is( $got, $expected, $caption );
__END__
t/regression/chart_layout03.t view on Meta::CPAN
];
$worksheet->write( 'A1', $data );
$chart->add_series( values => '=Sheet1!$A$1:$A$5' );
$chart->add_series( values => '=Sheet1!$B$1:$B$5' );
$chart->add_series( values => '=Sheet1!$C$1:$C$5' );
$chart->set_legend(
position => 'overlay_right',
layout => {
x => 0.80197353455818043,
y => 0.3744240303295423,
width => 0.12858202099737534,
height => 0.25115157480314959,
}
);
$worksheet->insert_chart( 'E9', $chart );
t/regression/chart_layout06.t view on Meta::CPAN
];
$worksheet->write( 'A1', $data );
$chart->add_series( values => '=Sheet1!$A$1:$A$5' );
$chart->add_series( values => '=Sheet1!$B$1:$B$5' );
$chart->add_series( values => '=Sheet1!$C$1:$C$5' );
$chart->set_title(
name => 'Title',
overlay => 1,
layout => {
x => 0.42354155730533688,
y => 0.16203703703703703,
}
);
$worksheet->insert_chart( 'E9', $chart );
$workbook->close();
t/regression/chart_layout08.t view on Meta::CPAN
];
$worksheet->write( 'A1', $data );
$chart->add_series( values => '=Sheet1!$A$1:$A$5' );
$chart->add_series( values => '=Sheet1!$B$1:$B$5' );
$chart->add_series( values => '=Sheet1!$C$1:$C$5' );
$chart->set_title(
name_formula => '=Sheet1!$A$1', data => [1],
overlay => 1,
layout => {
x => 0.359652668416448,
y => 0.16203703703703703,
}
);
$worksheet->insert_chart( 'E9', $chart );
$workbook->close();
t/regression/chart_legend04.t view on Meta::CPAN
[ 3, 6, 9, 12, 15 ],
];
$worksheet->write( 'A1', $data );
$chart->add_series( values => '=Sheet1!$A$1:$A$5' );
$chart->add_series( values => '=Sheet1!$B$1:$B$5' );
$chart->add_series( values => '=Sheet1!$C$1:$C$5' );
$chart->set_legend( position => 'overlay_top_right' );
$worksheet->insert_chart( 'E9', $chart );
$workbook->close();
###############################################################################
#
# Compare the generated and existing Excel files.
#
t/regression/chart_pie04.t view on Meta::CPAN
];
$worksheet->write( 'A1', $data );
$chart->add_series(
categories => '=Sheet1!$A$1:$A$3',
values => '=Sheet1!$B$1:$B$3',
);
$chart->set_legend( position => 'overlay_right' );
$worksheet->insert_chart( 'E9', $chart );
$workbook->close();
###############################################################################
#
# Compare the generated and existing Excel files.
#