ag4ve has asked for the wisdom of the Perl Monks concerning the following question:
i'm having issues with the line names and values given for the x-axis. i have this code:
sub chart_me { my( $row, $name ) = @_; my $chart = $workbookout->add_chart( type => 'line', name => $name +); $chart->set_title( name => $name ); foreach my $i ( 1 .. 6 ) { my $rowi = $row + $i - 1; $chart->add_series( name => $header[ $i ], catagories => xl_range_formula( 'Sheet1', 1, 1, 2, $ma +xcol ), values => xl_range_formula( 'Sheet1', $rowi, $rowi +, 2, $maxcol ), ); } }
which generally works. my issue is that the value for 'name' should come from an array and instead is giving me "Row 2", "Row 3", etc. ie, "Row ".$i also, i can't find a way to get the values for the x-axis to be named as the date they come from (row 1) - i've got data from 2009-01 to 2010-12 and i'm getting 1 .. 24. is there any way to do this?
UPDATE
i did have some off by one issues, but correcting them just means that the data is fitting correctly in the graph - it didn't solve any of my issues.$chart->add_series( name => $header[ $i ], catagories => xl_range_formula( 'Sheet1', 0, 0, 1, $ma +xcol ), values => xl_range_formula( 'Sheet1', $rowi, $rowi +, 1, $maxcol ), );
UPDATE #2
i figured out that the 'name' for each line is actually given by the 'name_format' value. i'm now not entirely sure what 'name' is for. i plan to keep playing with it, and see if i can get some better / interesting results to pop out. my current add_series object definition looks like:
$chart->add_series( name => $header[ $i ], name_formula => '=Sheet1!' . xl_rowcol_to_cell( $rowi +, 0, 1, 1 ), catagories => xl_range_formula( 'Sheet1', 0, 0, 1, +$maxcol ), values => xl_range_formula( 'Sheet1', $rowi, $r +owi, 1, $maxcol ), );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with Spreadsheet::WriteExcel::Chart
by tilly (Archbishop) on Jan 24, 2011 at 06:35 UTC | |
by ag4ve (Monk) on Jan 24, 2011 at 12:19 UTC | |
|
Re: Help with Spreadsheet::WriteExcel::Chart
by Khen1950fx (Canon) on Jan 24, 2011 at 14:32 UTC | |
by ag4ve (Monk) on Jan 24, 2011 at 14:58 UTC |