Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to set x-axis label at the bottom(outside of chart) in a line chart

by jmcnamara (Monsignor)
on Mar 21, 2012 at 17:46 UTC ( #960829=note: print w/ replies, xml ) Need Help??


in reply to How to set x-axis label at the bottom(outside of chart) in a line chart

You can do this in Excel::Writer::XLSX using the label_position chart axis option set to low. Here is a small working example:

use strict; use warnings; use Excel::Writer::XLSX; # Create a workbook, a worksheet and a chart. my $workbook = Excel::Writer::XLSX->new( 'chart_axis.xlsx' ); my $worksheet = $workbook->add_worksheet(); my $chart = $workbook->add_chart( type => 'column', embedded = +> 1 ); # Some data to add to plot. my $data = [ [ 1, 2, -3, 4, 5 ], [ -2, 4, 6, 8, 10 ], [ 3, -6, 9, 12, 15 ], ]; # Write the data to the worksheet. $worksheet->write( 'A1', $data ); # Add three data series to the chart. $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_x_axis( label_position => 'low' ); # Insert the embedded chart. $worksheet->insert_chart( 'E9', $chart ); __END__

See the Excel::Writer::XLSX::Chart docs for details.

--
John.


Comment on Re: How to set x-axis label at the bottom(outside of chart) in a line chart
Download Code
Replies are listed 'Best First'.
Re^2: How to set x-axis label at the bottom(outside of chart) in a line chart
by satyas (Novice) on Mar 21, 2012 at 20:49 UTC

    Hi John, thanks a lot,it did the work.Its a new planet out there which i wasnt awre of.Thanks again.

Re^2: How to set x-axis label at the bottom(outside of chart) in a line chart
by satyas (Novice) on Mar 21, 2012 at 21:56 UTC

    HI John, one small thing...can we rotate the x-axis labels like 90% so that they show up verical? Do you have any code for that?Sorry for bugging you again...

      There isn't currently any way to manipulate the fonts on charts. This is a planned feature but I can't say when it will be available.

      --
      John.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960829]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2015-07-28 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls