Skip to content

PPTX chart conversion drops parent category labels #2502

Description

@pentaoa

PowerPoint charts with hierarchical category axes lose every parent label during conversion. A chart grouped by year and quarter becomes a table with repeated Q1 rows, making it impossible to tell which year's values each row describes.

Reproducer on main (eb31b5c), with markitdown[pptx] installed:

import io
from pptx import Presentation
from pptx.chart.data import CategoryChartData
from pptx.enum.chart import XL_CHART_TYPE
from pptx.util import Inches
from markitdown import MarkItDown

prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[6])
data = CategoryChartData()
for year in ("2024", "2025"):
    data.add_category(year).add_sub_category("Q1")
data.add_series("Sales", (10, 20))
slide.shapes.add_chart(
    XL_CHART_TYPE.COLUMN_CLUSTERED,
    Inches(1), Inches(1), Inches(8), Inches(5), data,
)
stream = io.BytesIO()
prs.save(stream)
stream.seek(0)
print(MarkItDown().convert_stream(stream, file_extension=".pptx").markdown)

Actual table:

| Category | Sales |
|---|---|
| Q1 | 10.0 |
| Q1 | 20.0 |

Expected: retain both 2024 / Q1 and 2025 / Q1 (or otherwise include the parent labels), with each row's values unchanged.

PptxConverter iterates the leaf categories. python-pptx exposes the complete parent-to-child paths through Categories.flattened_labels. This also reproduces with three category levels. I have a focused fix and in-memory PPTX regression tests ready.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions