To be able to help you, I added the use-modules at the top, plus I aliased the CSV bareword-filehandle to the built-in DATA bareword-filehandle, so that reading from <CSV> will actually read from the __DATA__ section at the end of the file:
... to the top. And then I created the __DATA__ section at the end of the script, with some CSV-style data:#!perl use 5.012; # strict, // use warnings; use Excel::Writer::XLSX; *CSV = *DATA; # makes CSV an alias to the __DATA__ section, so I can + add CSV data to the end of the script, rather than creating a separa +te file; you will not want this line in your application
__DATA__ freq,b xtalk 10,0.000001 20,0.000002 50,0.000005 100,1.00E-05 200,2.00E-05 500,5.00E-05 1000,1.00E-04
(I only did columns A:B; data in C:E wasn't necessary to prove that the legend and chart will work.)
For your program, you won't need the *CSV = *DATA, nor the __DATA__ section at the end, because presumably you already opened CSV in some line of code not shown to us. (Read perldoc -f open, and learn to use lexical filehandles rather than the old-fashioned bareword filehandles. And don't forget to check for success on your open: it's easiest to do that automatically by using use autodie;)
With the solidfill legend code in there, it gives me the warning
and doesn't create the chart at all. If I comment that out, so none of the set_legend calls are active, I get a chart that I think matches your expectation (though the legend is on the center-right and isn't formatted).Can't use string ("solidfill") as a HASH ref while "strict refs" in us +e at c:/usr/local/apps/berrybrew/perls/system/perl/site/lib/Excel/Wri +ter/XLSX/Chart.pm line 1158.
I don't know where you got fill=>'solidfill', as I don't see "solidfill" anywhere in the chart formatting section. I tried
... and it put it over the chart in the top right with a red background, which is what I'd expect.$chart->set_legend( position => 'overlay_top_right', fill => { color => 'red' }, );
You claimed
... but the documentation actually says in the set_legend() section,#$chart->set_legend({ 'font'=> { 'bold' => 1, 'italic' => 1}}); <<== t +aken from CPAN example, it generates error
... Notice, it only has one pair of braces, not two like in your code. Using exactly the line that the POD shows, I get a legend on the far right whose labels are bold and italic.$chart->set_legend( font => { bold => 1, italic => 1 } );
Combining it all together
$chart->set_legend( position => 'overlay_top_right', fill => { color => 'red' }, font => { 'bold' => 1, 'italic' => 1}, );
I get upper right, red background, bold and italic, exactly as I would expect.
In reply to Re^3: XLSX::Chart legend question
by pryrt
in thread XLSX::Chart legend question
by smh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |