Skip to content

fix(pptx): read the series of every chart plot - #4811

Merged
DanielNg0729 merged 5 commits into
docling-project:mainfrom
DanielNg0729:feat/pptx-read-3d-stock-plots
Oct 25, 2026
Merged

DanielNg0729 merged 5 commits into
docling-project:mainfrom
DanielNg0729:feat/pptx-read-3d-stock-plots

Conversation

@DanielNg0729

Copy link
Copy Markdown
Member

Summary

This is a follow-up to #4773 (issue #4772).

python-pptx has no plot class for some plot types: 3-D bar, 3-D line, 3-D pie, stock, surface and bar-of-pie. #4773 classifies such a plot as other_chart and skips its series with a warning. A chart that has only such a plot therefore has no data table.

python-pptx has a plot class for a 3-D area plot, but no series class for it. When the backend reads its series, python-pptx raises NotImplementedError. The backend does not catch this error, so one 3-D area chart stops the conversion of the whole presentation (RuntimeError: Pipeline SimplePipeline failed).

This PR changes the PowerPoint backend only.

  • The backend reads the series of every plot. All c:ser elements have the
    same structure, so one python-pptx series class can read the series of any
    plot type. XySeries reads scatter and bubble plots, which keep their
    values in c:yVal. BarSeries reads all other plots, which keep their
    values in c:val.
  • The backend reads the category labels from the first series. python-pptx's
    plot.categories does the same. A multi-level axis still gives the labels of
    its leaf level.
  • The backend classifies each plot by its XML tag. The mapping is the same as
    in the Word and Excel backends. bar3DChart is now bar_chart,
    line3DChart is line_chart, and pie3DChart is pie_chart. Stock,
    surface, 3-D area and bar-of-pie plots stay other_chart, as they are in
    Word and Excel.
  • The warning about skipped plots is removed, because the backend does not
    skip a plot now.

The output does not change for the plot types that python-pptx could already read. I compared column, line, pie, doughnut, area, radar, scatter, bubble and multi-level category charts before and after this change.

Change in the reference data

Slide 2 of tests/data/pptx/sources/pptx_chart.pptx has a 3-D clustered column chart (c:bar3DChart). This PR changes its output in pptx_chart.pptx.json and pptx_chart.pptx.md:

  • Before: "Other chart", with no data table.

  • After: "Bar chart", with this data table:

    2026
    Q1 10
    Q2 20
    Q3 30

These values are the values in the data cache of the chart (ppt/charts/chart2.xml). The .itxt file does not change. The other
reference files do not change. The second commit contains only this reference-data change.

Tests

  • test_plot_without_a_python_pptx_class_keeps_its_data makes one chart for
    each plot type: 3-D bar, 3-D line, 3-D pie, 3-D area, bar-of-pie, stock,
    surface and 3-D surface. Each chart must keep its label and its data. All 8
    cases fail on main. The 3-D area case fails with the pipeline error.
  • test_stock_plot_keeps_its_series_next_to_the_other_plots replaces
    test_unreadable_plot_keeps_the_data_of_the_other_plots. The stock series
    now come after the column series in the data table.
  • test_chart_parsed_as_classified_picture_with_data now checks the
    classification and the data of slide 2.

Related PR

PR #4380 by @chrikrah fixes the same 3-D area error. It catches NotImplementedError, so the chart is kept but has no data. With this PR, the chart keeps its data too. #4380 is based on the code before #4773. I can help to coordinate the two PRs if the maintainers prefer a different order.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

python-pptx has no plot class for 3-D bar, line and pie, stock,
surface and bar-of-pie plots. The backend skipped the series of such a
plot and classified it as other_chart. python-pptx also has no series
class for a 3-D area plot, so that chart stopped the conversion of the
whole presentation with NotImplementedError.

Every c:ser element has the same structure, so a python-pptx series
class reads the series of any plot. Read the categories from the first
series, as python-pptx does. Classify each plot by its tag, as the Word
and Excel backends do, so bar3DChart is a bar chart.

Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
Slide 2 of pptx_chart.pptx holds a 3-D clustered column chart
(c:bar3DChart). It changes from "other_chart" with no data table to
"bar_chart" with its data: one series "2026" with 10, 20 and 30 over
Q1 to Q3. These are the values in the chart's data cache.

Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @DanielNg0729, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

🟢 Require two reviewer for test updates

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working pptx issue related to pptx backend labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit d572724bd8. The analysis read the diff only. It did not run code from this pull request.

The PowerPoint backend now reads the series of every chart plot through the XML tag. 3-D bar, line and pie plots keep their type and data, and a 3-D area chart no longer stops the conversion of the whole presentation.

CI safety: no concern found. A maintainer must still approve CI.

4 related pull request(s) in the same code
PR State Signal Assessment
#4773 merged referenced as #4773; also references issue #4772 related: This merged PR added the multi-plot chart code. This PR is a follow-up that changes how that code reads plots and series. It does not repeat the same change.
#4443 open changes the same code related: It changes run-level text formatting and hyperlinks in the same backend file. It does not touch chart code.
#4812 merged also references issue #4772 related: This merged PR moves the chart table builder into a shared module and applies the same plot-series idea to Excel. It does not make the same change as this PR.
#4380 closed referenced as #4380 related: This closed, unmerged PR also targets the NotImplementedError from a 3-D area chart. It drops the chart data. This PR reads the data instead.

Reference data changes

Change Files
tables 1
text 1
  • tables tests/data/pptx/groundtruth/pptx_chart.pptx.md: +7 / -1 lines; Markdown table rows changed
  • text tests/data/pptx/groundtruth/pptx_chart.pptx.json: item attributes changed

Assessment: expected. The PR now reads the data of the c:bar3DChart plot on slide 2 of pptx_chart.pptx. A new data table in the Markdown and JSON output matches that change. The updated test asserts the same grid.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/mspowerpoint_backend.py 90.62% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

dolfim-ibm
dolfim-ibm previously approved these changes Oct 14, 2026

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dolfim-ibm

Copy link
Copy Markdown
Member

One blocker, plus a follow-up suggestion.

Blocker: a malformed series in a 3-D, stock, surface or bar-of-pie plot now fails the whole presentation.

_plot_series and _category_labels now read c:order and c:pt/c:v for plot types that main skipped. When one of these elements is missing, python-pptx raises InvalidXmlError, but the call site around _chart_to_table_data catches only (AttributeError, ValueError, KeyError).

Sample main this PR
stockChart, c:ser without c:order OK (other_chart, no data) RuntimeError: Pipeline SimplePipeline failed
stockChart, c:pt without c:v OK RuntimeError: Pipeline SimplePipeline failed
barChart, same two defects fails fails (shared with main)

The fix is to add InvalidXmlError (already imported) to that except tuple. That also fixes the barChart case that is shared with main. Please add a one-case regression test, for example a stock plot whose c:ser has no c:order. The purpose of this PR is that one bad chart must not stop the conversion, so this gap belongs here.

Suggestion (not blocking): _CHART_TAGNAME_TO_CLASSIFICATION is now identical in the Word, Excel and PowerPoint backends. A shared module would keep the three in sync.

Classifying by tag aligns the PowerPoint backend with Word and Excel, which is good. Using BarSeries for series that are not bar series relies on all c:ser elements having the same structure. That is acceptable here.

The backend now reads the series and categories of 3-D, stock, surface
and bar-of-pie plots. When a c:ser has no c:order, or a c:pt has no
c:v, python-pptx raises InvalidXmlError. The call site did not catch
this error, so one malformed chart stopped the conversion of the whole
presentation. A bar chart with the same defects failed on main too.

Catch InvalidXmlError where the chart data is read. The chart keeps
its classification without a data table, and a warning names the
missing element.

Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
…tock-plots

Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
@github-actions github-actions Bot removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem labels Oct 14, 2026
@DanielNg0729

Copy link
Copy Markdown
Member Author

hi Dr @dolfim-ibm, thank you very much, i have added some commit to resolve your point for this PR as well. This PR is ready for your review again when you have a moment. Thanks again!

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem labels Oct 14, 2026
@dolfim-ibm

Copy link
Copy Markdown
Member

#4812 is now merged, and this PR conflicts with main. Please update the branch with the latest main (merge or rebase), and regenerate the affected ground truth if needed. After CI is green, this is ready for the final review.

This PR also covers the c:area3DChart crash that @chrikrah reported and fixed first in #4380. We will continue with this PR and close #4380, with credit to @chrikrah for finding the issue.

…tock-plots

Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
@github-actions github-actions Bot removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem labels Oct 19, 2026
@DanielNg0729

Copy link
Copy Markdown
Member Author

Thank you very much @dolfim-ibm, I merged the latest main. The chart table code now uses the shared build_chart_table from #4812. The PowerPoint reference data did not need another update. When I regenerate it, the only change is still slide 2 of pptx_chart.pptx, as before.
Thank you @chrikrah for finding the c:area3DChart crash in #4380.

@github-actions github-actions Bot added the ai:ci-safe AI triage found no CI-safety concern (advisory) label Oct 19, 2026

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chrikrah chrikrah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielNg0729 closing my #4380 for this was the right call: the c:area3DChart deck I attached there now converts with its data table, where mine kept only a picture. The InvalidXmlError path @dolfim-ibm flagged degrades to a chart without a table, and I'd merge this at d572724.

$ PYTHONPATH=$PWD python -m pytest tests/test_backend_pptx.py tests/test_backend_pptx_charts.py -q
72 passed in 12.54s

# same tests, docling/backend/mspowerpoint_backend.py taken from merge base 0b62ddd2
12 failed, 60 passed in 10.57s
# area3DChart at base: NotImplementedError "series class ... not yet implemented",
# then RuntimeError: Pipeline SimplePipeline failed
# ruff 0.15.12 check and format: clean; python-pptx 1.0.2, pytest 9.0.3
# not run: suites beyond the pptx backend

non-blocking: slide 2 of pptx_chart.pptx changes from "Other chart" with no table to "Bar chart" with one. Anyone filtering on OTHER_CHART for 3-D bars will see that move, so it deserves a line in the release notes.

@PeterStaar-IBM, Mergify wants a second approval for the ground-truth update, the same rule you cleared on #4812. @ceberam, slide 2 comes from your #3972, so the move to "Bar chart" may want your view. Could one of you review it this week?

@PeterStaar-IBM PeterStaar-IBM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@DanielNg0729
DanielNg0729 merged commit 90234a7 into docling-project:main Oct 25, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working pptx issue related to pptx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants