python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

bug: XML Schema specifies `c:rich` where `c:txPr` should go

Open rileym99 opened this issue 6 months ago • 5 comments

Hello,

I am trying to use python-pptx to turn off wrapping for all data labels in a bar chart XL_CHART_TYPE.BAR_CLUSTERED. To do this I have the following code, which I believe should work based on the documentation here: https://python-pptx.readthedocs.io/en/latest/api/text.html?highlight=word_wrap#pptx.text.text.TextFrame.word_wrap

for s in chart.series:
    dl = s.points[0].data_label
    dl.text_frame.word_wrap = False

When I run this it appears to have no effect. I've inspected the chart xml and there is no wrap setting set in bodyPr - part of the xml is reproduced below:

<c:dLbls>
  <c:dLbl>
    <c:idx val="0"/>
    <c:tx>
      <c:rich>
        <a:bodyPr/>
        <a:lstStyle/>

I have been able to set the property directly in the xml with this code:

for s in chart.series:
    dl = s.points[0].data_label._element.dLbls
    txPr = dl.get_or_add_txPr()
    txPr.bodyPr.set('wrap', 'none')

Please could you investigate this?

Thanks, Matthew Riley

rileym99 avatar Jun 25 '25 11:06 rileym99