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:

<c:ser> <c:idx val="0"/> <c:order val="0"/> <c:cat> <c:numRef> <c:f>Sheet1!$A$2:$A$7</c:f>
vs modified:
<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>
... The modified version adds the <c:explosion val="5"/> empty tag.

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.


In reply to Re: XLSX::Chart::Pie -> Exploding by pryrt
in thread XLSX::Chart::Pie -> Exploding by sectokia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.