Charts: axis c:spPr is appended out of OOXML schema order

Open Beginner friendly
#648 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in sdpm/sdpm/engine/builder/elements/chart.py, in the “Axis lines” block of _add_chart, and check the other c:spPr insertions against the axis schema order. Build bar and line charts, then verify that c:spPr precedes c:txPr and c:crossAx in c:valAx and c:catAx; run ruff and pytest sdpm/tests/test_chart_roundtrip.py, and add a Fixed entry under [Unreleased] in CHANGELOG.md.

Written by the indexing model from the issue text.

Description

bug good first issue

Summary

When the chart builder styles the axis line, it adds the axis c:spPr with etree.SubElement(ax_el, qn('c:spPr')). That appends it as the last child of c:valAx / c:catAx. In the OOXML schema (CT_ValAx / CT_CatAx), c:spPr belongs after c:tickLblPos and before c:txPr / c:crossAx. So the generated chart XML is out of schema order.

Where

sdpm/sdpm/engine/builder/elements/chart.py, the "Axis lines" block in _add_chart (two places: the themed default and the valueAxis.line == "none" branch). The same pattern may apply to other SubElement(..., 'c:spPr') calls in that function; worth checking each against the schema.

Why it matters

As far as I know, PowerPoint accepts this today, so it is a latent problem rather than a visible one. I have not tested every Office version. Strict consumers and validators can reject it, and it will bite when a new chart type (see #620, #621, #622) reuses this code.

Expected

Insert c:spPr at its schema position instead of appending. For example, insert it before the first existing c:txPr, c:crossAx or c:crosses child, or immediately after c:tickLblPos when present.

Done when

  • A helper (for example _insert_in_order) puts c:spPr in the right place for c:valAx and c:catAx.
  • A test builds a bar and a line chart (the types that have axes) and checks that, in c:valAx and c:catAx, c:spPr comes before c:txPr and c:crossAx.
  • CHANGELOG.md [Unreleased] has a Fixed entry.
  • ruff and pytest sdpm/tests/test_chart_roundtrip.py pass.

This is a good first issue: one file, one helper, one test.

🤖 Created by Kiro Crew

Dominant language
Python
Stars
136
Forks
13
Avg merge
7h 43m
Merged PRs (30d)
180

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws-samples/sample-spec-driven-presentation-maker

All issues in aws-samples/sample-spec-driven-presentation-maker

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.