.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Spreadsheet::WriteExcel::Chart 3" .TH Spreadsheet::WriteExcel::Chart 3 "2010-02-03" "perl v5.8.4" "User Contributed Perl Documentation" .SH "NAME" Chart \- A writer class for Excel Charts. .SH "SYNOPSIS" .IX Header "SYNOPSIS" To create a simple Excel file with a chart using Spreadsheet::WriteExcel: .PP .Vb 1 \& #!/usr/bin/perl -w .Ve .PP .Vb 2 \& use strict; \& use Spreadsheet::WriteExcel; .Ve .PP .Vb 2 \& my $workbook = Spreadsheet::WriteExcel->new( 'chart.xls' ); \& my $worksheet = $workbook->add_worksheet(); .Ve .PP .Vb 1 \& my $chart = $workbook->add_chart( type => 'column' ); .Ve .PP .Vb 5 \& # Configure the chart. \& $chart->add_series( \& categories => '=Sheet1!$A$2:$A$7', \& values => '=Sheet1!$B$2:$B$7', \& ); .Ve .PP .Vb 5 \& # Add the worksheet data the chart refers to. \& my $data = [ \& [ 'Category', 2, 3, 4, 5, 6, 7 ], \& [ 'Value', 1, 4, 5, 2, 1, 5 ], \& ]; .Ve .PP .Vb 1 \& $worksheet->write( 'A1', $data ); .Ve .PP .Vb 1 \& __END__ .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Chart\*(C'\fR module is an abstract base class for modules that implement charts in Spreadsheet::WriteExcel. The information below is applicable to all of the available subclasses. .PP The \f(CW\*(C`Chart\*(C'\fR module isn't used directly, a chart object is created via the Workbook \f(CW\*(C`add_chart()\*(C'\fR method where the chart type is specified: .PP .Vb 1 \& my $chart = $workbook->add_chart( type => 'column' ); .Ve .PP Currently the supported chart types are: .ie n .IP "* ""area"": Creates an Area (filled line) style chart. See Spreadsheet::WriteExcel::Chart::Area." 4 .el .IP "* \f(CWarea\fR: Creates an Area (filled line) style chart. See Spreadsheet::WriteExcel::Chart::Area." 4 .IX Item "area: Creates an Area (filled line) style chart. See Spreadsheet::WriteExcel::Chart::Area." .PD 0 .ie n .IP "* ""bar"": Creates a Bar style (transposed histogram) chart. See Spreadsheet::WriteExcel::Chart::Bar." 4 .el .IP "* \f(CWbar\fR: Creates a Bar style (transposed histogram) chart. See Spreadsheet::WriteExcel::Chart::Bar." 4 .IX Item "bar: Creates a Bar style (transposed histogram) chart. See Spreadsheet::WriteExcel::Chart::Bar." .ie n .IP "* ""column"": Creates a column style (histogram) chart. See Spreadsheet::WriteExcel::Chart::Column." 4 .el .IP "* \f(CWcolumn\fR: Creates a column style (histogram) chart. See Spreadsheet::WriteExcel::Chart::Column." 4 .IX Item "column: Creates a column style (histogram) chart. See Spreadsheet::WriteExcel::Chart::Column." .ie n .IP "* ""line"": Creates a Line style chart. See Spreadsheet::WriteExcel::Chart::Line." 4 .el .IP "* \f(CWline\fR: Creates a Line style chart. See Spreadsheet::WriteExcel::Chart::Line." 4 .IX Item "line: Creates a Line style chart. See Spreadsheet::WriteExcel::Chart::Line." .ie n .IP "* ""pie"": Creates an Pie style chart. See Spreadsheet::WriteExcel::Chart::Pie." 4 .el .IP "* \f(CWpie\fR: Creates an Pie style chart. See Spreadsheet::WriteExcel::Chart::Pie." 4 .IX Item "pie: Creates an Pie style chart. See Spreadsheet::WriteExcel::Chart::Pie." .ie n .IP "* ""scatter"": Creates an Scatter style chart. See Spreadsheet::WriteExcel::Chart::Scatter." 4 .el .IP "* \f(CWscatter\fR: Creates an Scatter style chart. See Spreadsheet::WriteExcel::Chart::Scatter." 4 .IX Item "scatter: Creates an Scatter style chart. See Spreadsheet::WriteExcel::Chart::Scatter." .ie n .IP "* ""stock"": Creates an Stock style chart. See Spreadsheet::WriteExcel::Chart::Stock." 4 .el .IP "* \f(CWstock\fR: Creates an Stock style chart. See Spreadsheet::WriteExcel::Chart::Stock." 4 .IX Item "stock: Creates an Stock style chart. See Spreadsheet::WriteExcel::Chart::Stock." .PD .PP More charts and sub-types will be supported in time. See the \*(L"\s-1TODO\s0\*(R" section. .PP Methods that are common to all chart types are documented below. .SH "CHART METHODS" .IX Header "CHART METHODS" .Sh "\fIadd_series()\fP" .IX Subsection "add_series()" In an Excel chart a \*(L"series\*(R" is a collection of information such as values, x\-axis labels and the name that define which data is plotted. These settings are displayed when you select the \f(CW\*(C`Chart \-> Source Data...\*(C'\fR menu option. .PP With a Spreadsheet::WriteExcel chart object the \f(CW\*(C`add_series()\*(C'\fR method is used to set the properties for a series: .PP .Vb 6 \& $chart->add_series( \& categories => '=Sheet1!$A$2:$A$10', \& values => '=Sheet1!$B$2:$B$10', \& name => 'Series name', \& name_formula => '=Sheet1!$B$1', \& ); .Ve .PP The properties that can be set are: .ie n .IP "* ""values""" 4 .el .IP "* \f(CWvalues\fR" 4 .IX Item "values" This is the most important property of a series and must be set for every chart object. It links the chart with the worksheet data that it displays. Note the format that should be used for the formula. See \*(L"Working with Cell Ranges\*(R". .ie n .IP "* ""categories""" 4 .el .IP "* \f(CWcategories\fR" 4 .IX Item "categories" This sets the chart category labels. The category is more or less the same as the X\-axis. In most chart types the \f(CW\*(C`categories\*(C'\fR property is optional and the chart will just assume a sequential series from \f(CW\*(C`1 .. n\*(C'\fR. .ie n .IP "* ""name""" 4 .el .IP "* \f(CWname\fR" 4 .IX Item "name" Set the name for the series. The name is displayed in the chart legend and in the formula bar. The name property is optional and if it isn't supplied will default to \f(CW\*(C`Series 1 .. n\*(C'\fR. .ie n .IP "* ""name_formula""" 4 .el .IP "* \f(CWname_formula\fR" 4 .IX Item "name_formula" Optional, can be used to link the name to a worksheet cell. See \*(L"Chart names and links\*(R". .PP You can add more than one series to a chart, in fact some chart types such as \f(CW\*(C`stock\*(C'\fR require it. The series numbering and order in the final chart is the same as the order in which that are added. .PP .Vb 6 \& # Add the first series. \& $chart->add_series( \& categories => '=Sheet1!$A$2:$A$7', \& values => '=Sheet1!$B$2:$B$7', \& name => 'Test data series 1', \& ); .Ve .PP .Vb 6 \& # Add another series. Category is the same but values are different. \& $chart->add_series( \& categories => '=Sheet1!$A$2:$A$7', \& values => '=Sheet1!$C$2:$C$7', \& name => 'Test data series 2', \& ); .Ve .Sh "\fIset_x_axis()\fP" .IX Subsection "set_x_axis()" The \f(CW\*(C`set_x_axis()\*(C'\fR method is used to set properties of the X axis. .PP .Vb 1 \& $chart->set_x_axis( name => 'Sample length (m)' ); .Ve .PP The properties that can be set are: .ie n .IP "* ""name""" 4 .el .IP "* \f(CWname\fR" 4 .IX Item "name" Set the name (title or caption) for the axis. The name is displayed below the X axis. This property is optional. The default is to have no axis name. .ie n .IP "* ""name_formula""" 4 .el .IP "* \f(CWname_formula\fR" 4 .IX Item "name_formula" Optional, can be used to link the name to a worksheet cell. See \*(L"Chart names and links\*(R". .PP Additional axis properties such as range, divisions and ticks will be made available in later releases. See the \*(L"\s-1TODO\s0\*(R" section. .Sh "\fIset_y_axis()\fP" .IX Subsection "set_y_axis()" The \f(CW\*(C`set_y_axis()\*(C'\fR method is used to set properties of the Y axis. .PP .Vb 1 \& $chart->set_y_axis( name => 'Sample weight (kg)' ); .Ve .PP The properties that can be set are: .ie n .IP "* ""name""" 4 .el .IP "* \f(CWname\fR" 4 .IX Item "name" Set the name (title or caption) for the axis. The name is displayed to the left of the Y axis. This property is optional. The default is to have no axis name. .ie n .IP "* ""name_formula""" 4 .el .IP "* \f(CWname_formula\fR" 4 .IX Item "name_formula" Optional, can be used to link the name to a worksheet cell. See \*(L"Chart names and links\*(R". .PP Additional axis properties such as range, divisions and ticks will be made available in later releases. See the \*(L"\s-1TODO\s0\*(R" section. .Sh "\fIset_title()\fP" .IX Subsection "set_title()" The \f(CW\*(C`set_title()\*(C'\fR method is used to set properties of the chart title. .PP .Vb 1 \& $chart->set_title( name => 'Year End Results' ); .Ve .PP The properties that can be set are: .ie n .IP "* ""name""" 4 .el .IP "* \f(CWname\fR" 4 .IX Item "name" Set the name (title) for the chart. The name is displayed above the chart. This property is optional. The default is to have no chart title. .ie n .IP "* ""name_formula""" 4 .el .IP "* \f(CWname_formula\fR" 4 .IX Item "name_formula" Optional, can be used to link the name to a worksheet cell. See \*(L"Chart names and links\*(R". .Sh "\fIset_legend()\fP" .IX Subsection "set_legend()" The \f(CW\*(C`set_legend()\*(C'\fR method is used to set properties of the chart legend. .PP .Vb 1 \& $chart->set_legend( position => 'none' ); .Ve .PP The properties that can be set are: .ie n .IP "* ""position""" 4 .el .IP "* \f(CWposition\fR" 4 .IX Item "position" Set the position of the chart legend. .Sp .Vb 1 \& $chart->set_legend( position => 'none' ); .Ve .Sp The default legend position is \f(CW\*(C`bottom\*(C'\fR. The currently supported chart positions are: .Sp .Vb 2 \& none \& bottom .Ve .Sp The other legend positions will be added soon. .Sh "\fIset_chartarea()\fP" .IX Subsection "set_chartarea()" The \f(CW\*(C`set_chartarea()\*(C'\fR method is used to set the properties of the chart area. In Excel the chart area is the background area behind the chart. .PP The properties that can be set are: .ie n .IP "* ""color""" 4 .el .IP "* \f(CWcolor\fR" 4 .IX Item "color" Set the colour of the chart area. The Excel default chart area color is 'white', index 9. See \*(L"Chart object colours\*(R". .ie n .IP "* ""line_color""" 4 .el .IP "* \f(CWline_color\fR" 4 .IX Item "line_color" Set the colour of the chart area border line. The Excel default border line colour is 'black', index 9. See \*(L"Chart object colours\*(R". .ie n .IP "* ""line_pattern""" 4 .el .IP "* \f(CWline_pattern\fR" 4 .IX Item "line_pattern" Set the pattern of the of the chart area border line. The Excel default pattern is 'none', index 0 for a chart sheet and 'solid', index 1, for an embedded chart. See \*(L"Chart line patterns\*(R". .ie n .IP "* ""line_weight""" 4 .el .IP "* \f(CWline_weight\fR" 4 .IX Item "line_weight" Set the weight of the of the chart area border line. The Excel default weight is 'narrow', index 2. See \*(L"Chart line weights\*(R". .PP Here is an example of setting several properties: .PP .Vb 6 \& $chart->set_chartarea( \& color => 'red', \& line_color => 'black', \& line_pattern => 2, \& line_weight => 3, \& ); .Ve .PP Note, for chart sheets the chart area border is off by default. For embedded charts is is on by default. .Sh "\fIset_plotarea()\fP" .IX Subsection "set_plotarea()" The \f(CW\*(C`set_plotarea()\*(C'\fR method is used to set properties of the plot area of a chart. In Excel the plot area is the area between the axes on which the chart series are plotted. .PP The properties that can be set are: .ie n .IP "* ""visible""" 4 .el .IP "* \f(CWvisible\fR" 4 .IX Item "visible" Set the visibility of the plot area. The default is 1 for visible. Set to 0 to hide the plot area and have the same colour as the background chart area. .ie n .IP "* ""color""" 4 .el .IP "* \f(CWcolor\fR" 4 .IX Item "color" Set the colour of the plot area. The Excel default plot area color is 'silver', index 23. See \*(L"Chart object colours\*(R". .ie n .IP "* ""line_color""" 4 .el .IP "* \f(CWline_color\fR" 4 .IX Item "line_color" Set the colour of the plot area border line. The Excel default border line colour is 'gray', index 22. See \*(L"Chart object colours\*(R". .ie n .IP "* ""line_pattern""" 4 .el .IP "* \f(CWline_pattern\fR" 4 .IX Item "line_pattern" Set the pattern of the of the plot area border line. The Excel default pattern is 'solid', index 1. See \*(L"Chart line patterns\*(R". .ie n .IP "* ""line_weight""" 4 .el .IP "* \f(CWline_weight\fR" 4 .IX Item "line_weight" Set the weight of the of the plot area border line. The Excel default weight is 'narrow', index 2. See \*(L"Chart line weights\*(R". .PP Here is an example of setting several properties: .PP .Vb 6 \& $chart->set_plotarea( \& color => 'red', \& line_color => 'black', \& line_pattern => 2, \& line_weight => 3, \& ); .Ve .SH "WORKSHEET METHODS" .IX Header "WORKSHEET METHODS" In Excel a chart sheet (i.e, a chart that isn't embedded) shares properties with data worksheets such as tab selection, headers, footers, margins and print properties. .PP In Spreadsheet::WriteExcel you can set chart sheet properties using the same methods that are used for Worksheet objects. .PP The following Worksheet methods are also available through a non-embedded Chart object: .PP .Vb 8 \& get_name() \& activate() \& select() \& hide() \& set_first_sheet() \& protect() \& set_zoom() \& set_tab_color() .Ve .PP .Vb 6 \& set_landscape() \& set_portrait() \& set_paper() \& set_margins() \& set_header() \& set_footer() .Ve .PP See Spreadsheet::WriteExcel for a detailed explanation of these methods. .SH "EXAMPLE" .IX Header "EXAMPLE" Here is a complete example that demonstrates some of the available features when creating a chart. .PP .Vb 1 \& #!/usr/bin/perl -w .Ve .PP .Vb 2 \& use strict; \& use Spreadsheet::WriteExcel; .Ve .PP .Vb 3 \& my $workbook = Spreadsheet::WriteExcel->new( 'chart_area.xls' ); \& my $worksheet = $workbook->add_worksheet(); \& my $bold = $workbook->add_format( bold => 1 ); .Ve .PP .Vb 7 \& # 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 ], \& ]; .Ve .PP .Vb 2 \& $worksheet->write( 'A1', $headings, $bold ); \& $worksheet->write( 'A2', $data ); .Ve .PP .Vb 2 \& # Create a new chart object. In this case an embedded chart. \& my $chart = $workbook->add_chart( type => 'area', embedded => 1 ); .Ve .PP .Vb 6 \& # Configure the first series. (Sample 1) \& $chart->add_series( \& name => 'Sample 1', \& categories => '=Sheet1!$A$2:$A$7', \& values => '=Sheet1!$B$2:$B$7', \& ); .Ve .PP .Vb 6 \& # Configure the second series. (Sample 2) \& $chart->add_series( \& name => 'Sample 2', \& categories => '=Sheet1!$A$2:$A$7', \& values => '=Sheet1!$C$2:$C$7', \& ); .Ve .PP .Vb 4 \& # 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)' ); .Ve .PP .Vb 2 \& # Insert the chart into the worksheet (with an offset). \& $worksheet->insert_chart( 'D2', $chart, 25, 10 ); .Ve .PP .Vb 1 \& __END__ .Ve .SH "Chart object colours" .IX Header "Chart object colours" Many of the chart objects supported by Spreadsheet::WriteExcl allow the default colours to be changed. Excel provides a palette of 56 colours and in Spreadsheet::WriteExcel these colours are accessed via their palette index in the range 8..63. .PP The most commonly used colours can be accessed by name or index. .PP .Vb 6 \& black => 8, green => 17, navy => 18, \& white => 9, orange => 53, pink => 33, \& red => 10, gray => 23, purple => 20, \& blue => 12, lime => 11, silver => 22, \& yellow => 13, cyan => 15, \& brown => 16, magenta => 14, .Ve .PP For example the following are equivalent. .PP .Vb 2 \& $chart->set_plotarea( color => 10 ); \& $chart->set_plotarea( color => 'red' ); .Ve .PP The colour palette is shown in \f(CW\*(C`palette.html\*(C'\fR in the \f(CW\*(C`docs\*(C'\fR directory of the distro. An Excel version of the palette can be generated using \f(CW\*(C`colors.pl\*(C'\fR in the \f(CW\*(C`examples\*(C'\fR directory. .PP User defined colours can be set using the \f(CW\*(C`set_custom_color()\*(C'\fR workbook method. This and other aspects of using colours are discussed in the \*(L"Colours in Excel\*(R" section of the main Spreadsheet::WriteExcel documentation: . .SH "Chart line patterns" .IX Header "Chart line patterns" Chart lines patterns can be set using either an index or a name: .PP .Vb 2 \& $chart->set_plotarea( weight => 2 ); \& $chart->set_plotarea( weight => 'dash' ); .Ve .PP Chart lines have 9 possible patterns are follows: .PP .Vb 9 \& 'none' => 0, \& 'solid' => 1, \& 'dash' => 2, \& 'dot' => 3, \& 'dash-dot' => 4, \& 'dash-dot-dot' => 5, \& 'medium-gray' => 6, \& 'dark-gray' => 7, \& 'light-gray' => 8, .Ve .PP The patterns 1\-8 are shown in order in the drop down dialog boxes in Excel. The default pattern is 'solid', index 1. .SH "Chart line weights" .IX Header "Chart line weights" Chart lines weights can be set using either an index or a name: .PP .Vb 2 \& $chart->set_plotarea( weight => 1 ); \& $chart->set_plotarea( weight => 'hairline' ); .Ve .PP Chart lines have 4 possible weights are follows: .PP .Vb 4 \& 'hairline' => 1, \& 'narrow' => 2, \& 'medium' => 3, \& 'wide' => 4, .Ve .PP The weights 1\-4 are shown in order in the drop down dialog boxes in Excel. The default weight is 'narrow', index 2. .SH "Chart names and links" .IX Header "Chart names and links" The \f(CWadd_series())\fR, \f(CW\*(C`set_x_axis()\*(C'\fR, \f(CW\*(C`set_y_axis()\*(C'\fR and \f(CW\*(C`set_title()\*(C'\fR methods all support a \f(CW\*(C`name\*(C'\fR property. In general these names can be either a static string or a link to a worksheet cell. If you choose to use the \f(CW\*(C`name_formula\*(C'\fR property to specify a link then you should also the \f(CW\*(C`name\*(C'\fR property. This isn't strictly required by Excel but some third party applications expect it to be present. .PP .Vb 4 \& $chart->set_title( \& name => 'Year End Results', \& name_formula => '=Sheet1!$C$1', \& ); .Ve .PP These links should be used sparingly since they aren't commonly used in Excel charts. .SH "Chart names and Unicode" .IX Header "Chart names and Unicode" The \f(CWadd_series())\fR, \f(CW\*(C`set_x_axis()\*(C'\fR, \f(CW\*(C`set_y_axis()\*(C'\fR and \f(CW\*(C`set_title()\*(C'\fR methods all support a \f(CW\*(C`name\*(C'\fR property. These names can be \s-1UTF8\s0 strings if you are using perl 5.8+. .PP .Vb 2 \& # perl 5.8+ example: \& my $smiley = "\ex{263A}"; .Ve .PP .Vb 1 \& $chart->set_title( name => "Best. Results. Ever! $smiley" ); .Ve .PP For older perls you write Unicode strings as \s-1UTF\-16BE\s0 by adding a \f(CW\*(C`name_encoding\*(C'\fR property: .PP .Vb 2 \& # perl 5.005 example: \& my $utf16be_name = pack 'n', 0x263A; .Ve .PP .Vb 4 \& $chart->set_title( \& name => $utf16be_name, \& name_encoding => 1, \& ); .Ve .PP This methodology is explained in the \*(L"\s-1UNICODE\s0 \s-1IN\s0 \s-1EXCEL\s0\*(R" section of Spreadsheet::WriteExcel but is semi\-deprecated. If you are using Unicode the easiest option is to just use \s-1UTF8\s0 in perl 5.8+. .SH "Working with Cell Ranges" .IX Header "Working with Cell Ranges" In the section on \f(CW\*(C`add_series()\*(C'\fR it was noted that the series must be defined using a range formula: .PP .Vb 1 \& $chart->add_series( values => '=Sheet1!$B$2:$B$10' ); .Ve .PP The worksheet name must be specified (even for embedded charts) and the cell references must be \*(L"absolute\*(R" references, i.e., they must contain \f(CW\*(C`$\*(C'\fR signs. This is the format that is required by Excel for chart references. .PP Since it isn't very convenient to work with this type of string programmatically the Spreadsheet::WriteExcel::Utility module, which is included with Spreadsheet::WriteExcel, provides a function called \f(CW\*(C`xl_range_formula()\*(C'\fR to convert from zero based row and column cell references to an A1 style formula string. .PP The syntax is: .PP .Vb 1 \& xl_range_formula($sheetname, $row_1, $row_2, $col_1, $col_2) .Ve .PP If you include it in your program, using the standard import syntax, you can use the function as follows: .PP .Vb 3 \& # Include the Utility module or just the function you need. \& use Spreadsheet::WriteExcel::Utility qw( xl_range_formula ); \& ... .Ve .PP .Vb 5 \& # Then use it as required. \& $chart->add_series( \& categories => xl_range_formula( 'Sheet1', 1, 9, 0, 0 ), \& values => xl_range_formula( 'Sheet1', 1, 9, 1, 1 );, \& ); .Ve .PP .Vb 5 \& # Which is the same as: \& $chart->add_series( \& categories => '=Sheet1!$A$2:$A$10', \& values => '=Sheet1!$B$2:$B$10', \& ); .Ve .PP See Spreadsheet::WriteExcel::Utility for more details. .SH "TODO" .IX Header "TODO" Charts in Spreadsheet::WriteExcel are a work in progress. More chart types and features will be added in time. Please be patient. Even a small feature can take a week or more to implement, test and document. .PP Features that are on the \s-1TODO\s0 list and will be added are: .IP "* Chart sub\-types." 4 .IX Item "Chart sub-types." .PD 0 .IP "* Colours and formatting options. For now you will have to make do with the default Excel colours and formats." 4 .IX Item "Colours and formatting options. For now you will have to make do with the default Excel colours and formats." .IP "* Axis controls, gridlines." 4 .IX Item "Axis controls, gridlines." .IP "* 3D charts." 4 .IX Item "3D charts." .IP "* Embedded data in charts for third party application support. See Known Issues." 4 .IX Item "Embedded data in charts for third party application support. See Known Issues." .IP "* Additional chart types such as Bubble and Radar. Send an email if you are interested in other types and they will be added to the queue." 4 .IX Item "Additional chart types such as Bubble and Radar. Send an email if you are interested in other types and they will be added to the queue." .PD .PP If you are interested in sponsoring a feature let me know. .SH "KNOWN ISSUES" .IX Header "KNOWN ISSUES" .IP "* Currently charts don't contain embedded data from which the charts can be rendered. Excel and most other third party applications ignore this and read the data via the links that have been specified. However, some applications may complain or not render charts correctly. The preview option in Mac \s-1OS\s0 X is an known example. This will be fixed in a later release." 4 .IX Item "Currently charts don't contain embedded data from which the charts can be rendered. Excel and most other third party applications ignore this and read the data via the links that have been specified. However, some applications may complain or not render charts correctly. The preview option in Mac OS X is an known example. This will be fixed in a later release." .PD 0 .IP "* When there are several charts with titles set in a workbook some of the titles may display at a font size of 10 instead of the default 12 until another chart with the title set is viewed." 4 .IX Item "When there are several charts with titles set in a workbook some of the titles may display at a font size of 10 instead of the default 12 until another chart with the title set is viewed." .IP "* Stock (and other) charts should have the X\-axis dates aligned at an angle for clarity. This will be fixed at a later stage." 4 .IX Item "Stock (and other) charts should have the X-axis dates aligned at an angle for clarity. This will be fixed at a later stage." .PD .SH "AUTHOR" .IX Header "AUTHOR" John McNamara jmcnamara@cpan.org .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright \s-1MM\-MMX\s0, John McNamara. .PP All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.