smh has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XLSX::Chart legend question
by swl (Prior) on Mar 08, 2022 at 08:40 UTC | |
Can you reduce the problem to an SSCCE? That will increase the chances of people being able to help if they have not tried this exact process before. | [reply] |
by smh (Acolyte) on Mar 09, 2022 at 02:55 UTC | |
Below is the section of eth code that writes the worksheet and adds the chart.
| [reply] [d/l] |
by pryrt (Abbot) on Mar 09, 2022 at 14:45 UTC | |
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:
(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). 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. You claimed ... but the documentation actually says in the set_legend() section, ... 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. Combining it all together
I get upper right, red background, bold and italic, exactly as I would expect. | [reply] [d/l] [select] |