in reply to XLSX::Chart::Pie -> Exploding
The Excel::Writer::XLSX::Chart or Excel::Writer::XLSX::Chart::Pie add_series method don't seem to expose the explosion attribute for a chart series.
So, to see if I could work around it: I used the example in the SYNOPSIS of Excel::Writer::XLSX::Chart::Pie to create chart.xlsx without exploding pie pieces. I unzipped the chart1.xml from the original for reference. Then I used Excel to edit chart.xlsx to explode the pie to 5%, and extracted its chart1.xml. Looking at the differences, I think the critical point is at original:
vs modified:<c:ser> <c:idx val="0"/> <c:order val="0"/> <c:cat> <c:numRef> <c:f>Sheet1!$A$2:$A$7</c:f>
... The modified version adds the <c:explosion val="5"/> empty tag.<c:ser> <c:idx val="0"/> <c:order val="0"/> <c:explosion val="5"/> <c:cat> <c:numRef> <c:f>Sheet1!$A$2:$A$7</c:f>
I dug in a little, and unsuccessfully tried to monkey-patch things to include that extra xml tag (but I discovered after a lot of work I was patching in the wrong place). It looks like what needs to happen is the Excel::Writer::Chart::add_series method needs to be taught the explosion attribute; or similarly, Excel::Writer::Chart::Pie needs to define a wrapper around the parent add_series method which calls the parent, then appends the explosion attribute; and then whichever module is patched would have to also define _write_explosion to call $self->xml_empty_tag('c:explosion', val => $value;. If I find time later today, I might look into that more... but no guarantees (I think the best bet is to add the add_series-wrapper in ::Pie, and defining the _write_explosion() method in ::Pie as well).
Whatever happens, it is also a good idea to put in a feature request for Excel-Writer-XLSX to officially add the explosion attribute for charts (or at least pie charts) and the individual per-data-point explosion attribute as well (since you can explode individual slices). That is a feature that would be good to support natively, without monkey-patching.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XLSX::Chart::Pie -> Exploding
by pryrt (Abbot) on Oct 12, 2021 at 18:30 UTC |