question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting `Chart.has_title = False` doesn't work with doughnut

See original GitHub issue

Hello! Thanks for the work on this project 🙌

This is with python-pptx@0.6.10. Repro

chart_data = ChartData()
chart_data.categories = ['Yes', 'No']
chart_data.add_series('Series 1', (42, 24))

for chart_type in [XL_CHART_TYPE.PIE, XL_CHART_TYPE.DOUGHNUT]:
    for has_title in [True, False]:
        slide = presentation.slides.add_slide(presentation.slide_layouts[1])
        placeholder = slide.placeholders[13]
        chart = placeholder.insert_chart(chart_type, chart_data).chart
        chart.has_title = has_title

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
scannycommented, Sep 10, 2018

Should be fixed in release v0.6.13 later today.

1reaction
scannycommented, Jul 31, 2018

Okay, so here’s the logic that I think makes sense of this behavior. Just to recap, in a chart (of at least certain types) that has only one series, the name of the first series appears as the title of the chart without you actually asking PowerPoint to do that.

Leaving aside the question of whether this behavior is justified, the reason why this might be reasonable is that the title can substitute for the legend in this single-series case.

Generally, a legend maps a colors or symbol to a series, so you can tell which series is which. In the single-series case, you still need the name (what the values represent) but you no longer need the color-patch because there’s only one, or because the series uses a different color for each value (bar, segment) (common with pie and I expect doughnut charts, but also an option with bar charts).

So a useful option in this single-series case is to turn the legend off and let the title explain what the chart is representing. Anyway, opinions could differ on whether that’s “helping”, but at least it makes sense to me now why they might have done this on purpose.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VBA - New Chart is not adding title, legends, or deleting
The issue that I am running into is that my chart, that is created and placed into its own sheet, is saying that...
Read more >
Setting Chart Title through VBA sometimes works ... - MSDN
Method 'HasTitle' of object '_Chart' failed. Here's the code that causes the error. Dim chrt As Chart Set chrt = ActiveWorkbook.Charts.Add
Read more >
How to make doughnut chart with outside end labels
The only setting in doughnut charts given by Excel is data labels inside. Is it possible to make doughnut chart with outside end...
Read more >
Learn by Doing: Intro to VBA via Adding Charts Example
Section 1 – SETTING UP THE VBA EDITOR AND RUNNING OUR CODE. There are several different ways to add a chart to a...
Read more >
change the aspect ratio of a donut/pie chart #449 - GitHub
change the aspect ratio of a donut/pie chart #449 ... There is workaround to set ... None of these workarounds really work for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found