0
votes

When creating a new powerpoint slide with a line chart on it, I keep getting a chart title even though I didn't ask for one. I have tried all sorts of ways to get rid of it using combinations of chart.has_title=False or chart.has_text_frame = False and nothing seemed to work.

I looked at the diff between the xml when the chart was working well and now when it display this unwanted title. Among other things, there was this <c:autoTitleDeleted val="0"/> property. In the python-pptx chart.xmlwriter source code itself I changed the value to 1 and the chart title disappeared so I assume this is the root cause of this unwanted title–I have no idea why the autoTitleDeleted element is now being added to the xml from python-pptx.

I also saw this issue https://github.com/scanny/python-pptx/issues/460, but when I try to implement the fix I get the following error:

    autoTitleDeleted = chart_element.get_or_add_autoTitleDeleted()
AttributeError: 'CT_Chart' object has no attribute 'get_or_add_autoTitleDeleted'

And I can't find in the docs anywhere a get_or_add_audoTitleDeleted method nor in the source code.

I also tried changing the xml manually by simply doing this:

chart._element.xml = xml.replace('autoTitleDeleted val="0', 'autoTitleDeleted val="1')

But I get a AttributeError: can't set attribute

So I have 3 questions:

1) How can I resolve this?

2) For the future, when I find the xml causing an issue, how can I manually change it? Is there a library somewhere for xml manipulation?

3) Why is this autoTitleDeleted element being added in the first place?

1

1 Answers

1
votes

I would check your python-pptx version. This new attribute was added quite recently just for this reason. I recommend upgrading to the latest version 0.6.18 and see what happens. The fact that the traceback reports not finding that attribute is the evidence of a prior version. You can see the code that provides that attribute here:
https://github.com/scanny/python-pptx/blob/master/pptx/oxml/chart/chart.py#L40