Skip to content

fix(docx): write a chart in a table cell as its data table, and draw nothing of it over that table - #916

Merged
DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-chart-in-a-cell
Oct 18, 2026
Merged

DemchaAV merged 2 commits into
2.5-devfrom
fix/docx-chart-in-a-cell

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

The DOCX export writes every chart as its data table (writeChartFallback). A chart composed in a
table cell was drawn as well: a composed cell's content has no layout path of its own, its
fragments are among the table's, and drawCellDrawing draws the table's drawings — the chart's
bars and grid lines included. Measured in Word and LibreOffice on Windows, they stood in front of
the data table and hid its numbers ("Sales" read "Sa", 2.5 read "2."), and the chart's axis labels,
the page's text, were not drawn at all. The report said only "exported as its data table".

The log line said "the semantic DOCX export has no layout pass", and ChartNode's and
ChartDefinition's Javadoc, the charts recipe and the Word export example's caption said the same
or that the export "does not draw vector geometry". Neither holds: the export reads the layout and
draws geometry. What it does not write is a Word chart.

What changed

  • cellsBuiltFromAChart (in drawCellDrawing): the boxes of a table's cells whose drawing is
    a chart's alone (chartDrawnAlone — one chart, and beside it only paragraphs, lists, spacers,
    page breaks, alignments and sections or containers that paint nothing), every box the layout
    placed the cell in (a repeated header row has one a page). A table fragment those boxes hold
    (CellBox.holds) is not drawn; one that only reaches into them is. The chart is recorded in
    chartsNotDrawn, reset per export.
  • The chart's note: a chart composed in a cell that the export does not find drawing alone —
    beside other drawings, which it cannot tell its own from, or in a table composed in a cell, whose
    cells the layout gives no box — adds "its bars, lines and slices are drawn as well, where the page
    draws them, over the table and without its text".
  • The log line, writeChartFallback's Javadoc, ChartNode and ChartDefinition (core, Javadoc
    only), docs/recipes/charts.md, docs/recipes/docx-export.md, and WordExportExample's caption
    now say the export writes no Word chart; assets/readme/examples/word-export-companion.{docx,pdf}
    are re-rendered for the caption (CommittedAssetDriftTest named exactly those two).
  • CHANGELOG v2.5.0.

A drawing another cell pushes wholly into a chart's box — by a layer's offset or a margin below
zero — is taken for the chart's; the Javadoc says so.

Verification

  • Before → after, Word on Windows, a chart alone in a 300pt cell: bars and grid lines over a
    clipped data table → the data table alone.
  • ./mvnw -B -ntp test -f render-docx/pom.xml — DocxChartInACellTest (new, 9, each with-layout
    case asserting the layout stood behind it): a chart a cell is built from — its data table there,
    no drawing, the plain note, no "cell drawing" note; in an unpainted section, alone and under a
    caption, not drawn; beside a disc in its cell, drawn and named; two charts in a cell and a chart
    in a painted section, drawn and named; a neighbour's tile in its own cell, and one a margin below
    zero widens into the chart's cell, still drawn; a chart in a header row repeated over pages, and
    in a cell spanning two columns, drawn on no page; in a table composed in a cell, drawn and named;
    in the flow and with no layout, the plain note; one backend over two exports of one chart node.
  • 11 sabotages, each undoing one part — the skip, the record, the clause both ways, the reset, the
    drawing-alone walk, holds for overlaps, the first box only, the cell's own content only, two
    charts taken for one, a painted wrapper taken for nothing — all caught.
  • Corpus: 62/62 DOCX byte-identical; report notes 1246 → 1246.
  • ./mvnw -B -ntp clean verify — BUILD SUCCESS (core 821, render-docx 1755, examples 93, qa 1820); CommittedAssetDriftTest
    passes on the re-rendered example; the knowledge pack's --check and claims pass.

Lane: render-docx (semantic backend) — cell drawings and a report note; core Javadoc and the
example's caption.

…nothing of it over that table

A chart composed in a table cell was written as its data table, as a
chart is anywhere, and drawn as well: its fragments are among the
table's own, which the cell drawings draw. Measured in Word and
LibreOffice on Windows, its bars and grid lines stood over the data
table and hid its numbers ("Sales" read "Sa", 2.5 read "2."), without
its axis labels, while the report said it was exported as its data
table.

Where the chart is all its cell draws, alone or with text, lists,
spacers and wrappers that paint nothing beside it, every drawing the
layout places in the cell's box is the chart's, and none is drawn: the
chart is its data table there too. A chart beside other drawings in its
cell, whose drawings the export cannot tell from its own, or in a table
composed in a cell, whose cells the layout gives no box, is still
drawn, and its note now says so.

The export's log line, the chart's Javadoc, the charts recipe and the
Word export example said the export has no layout pass, or draws no
vector geometry; what it does not write is a Word chart. The example's
committed DOCX and PDF are re-rendered for its caption.
@DemchaAV
DemchaAV marked this pull request as draft October 18, 2026 18:58
…w nothing beside one

The set of charts not drawn holds the charts that are all their cell
draws, which its comment now says, with what keying it by identity
does to a chart node placed twice. The kinds that draw nothing beside a
chart are named as the set holds them.
@DemchaAV
DemchaAV marked this pull request as ready for review October 18, 2026 19:00
@DemchaAV
DemchaAV merged commit fcabb65 into 2.5-dev Oct 18, 2026
13 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-chart-in-a-cell branch October 18, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant