Bug 167821 - DOCX export: Chart X-axis labels overlap plotting area when Y values are negative
Summary: DOCX export: Chart X-axis labels overlap plotting area when Y values are nega...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
25.2.4.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: QA:needsComment
Keywords: filter:docx, implementationError
Depends on:
Blocks: OOXML-Chart Chart-Labels
  Show dependency treegraph
 
Reported: 2025-08-05 17:46 UTC by Piotr Osada
Modified: 2025-12-11 03:16 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
DOCX chart label position above X axis is not saved (158.72 KB, image/png)
2025-08-05 18:03 UTC, Piotr Osada
Details
Example spreadsheet (21.01 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-08-05 18:03 UTC, Piotr Osada
Details
Resulting DOCX (6.75 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-08-05 18:04 UTC, Piotr Osada
Details
*.DOCX/word/charts/chart1.xml Word and Writer comparison (Visual Studio) (408.08 KB, image/png)
2025-08-05 18:09 UTC, Piotr Osada
Details
WinMerge: search 'high' in chart1.xml (429.10 KB, image/png)
2025-08-05 18:14 UTC, Piotr Osada
Details
WinMerge: search 'nextTo' in chart1.xml (436.60 KB, image/png)
2025-08-05 18:15 UTC, Piotr Osada
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Osada 2025-08-05 17:46:47 UTC
In bar chart when all data are negative (minus values) it's better to place X axis labels above this (labels outside the plotting area). But Writer can't write this setting in XML chart when saving to DOCX. This result of return of the axis labels back to plotting area (below the X axis) after reloading the document.

1) Data:
A1:	A
A2:	-10

2) Make bar chart
3) Set labels outside (A category)
4) Select X Axis -> Format Axis -> Positioning -> Labels -> Place labels: Near axis (other side)
5) Paste chart to Writer
6) Save as DOCX
7) Reload

Result:
X Axis latels are inside ploting area (under the X axis).

Expected:
Labels above X axis.

Writer can't save 'high' and puts 'nextTo'd parameter in:
<c:chart>
 <c:plotArea>
  <c:catAx>
   <c:tickLblPos val="nextTo"/>
Comment 1 Piotr Osada 2025-08-05 18:03:04 UTC
Created attachment 202187 [details]
DOCX chart label position above X axis is not saved

Version: 25.2.4.3 (X86_64) / LibreOffice Community
Build ID: 33e196637044ead23f5c3226cde09b47731f7e27
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Raster; VCL: win
Locale: pl-PL (pl_PL); UI: en-US
Calc: CL threaded
Comment 2 Piotr Osada 2025-08-05 18:03:44 UTC
Created attachment 202188 [details]
Example spreadsheet
Comment 3 Piotr Osada 2025-08-05 18:04:25 UTC
Created attachment 202189 [details]
Resulting DOCX
Comment 4 Piotr Osada 2025-08-05 18:09:56 UTC
Created attachment 202190 [details]
*.DOCX/word/charts/chart1.xml Word and Writer comparison (Visual Studio)

Comparison of DOCX documents saved by Word and Writer.

LEFT chart from Excel pasted to Word
RIGHT chart form Calc pasted to Writer
Comment 5 Piotr Osada 2025-08-05 18:14:07 UTC
Created attachment 202191 [details]
WinMerge: search 'high' in chart1.xml
Comment 6 Piotr Osada 2025-08-05 18:15:15 UTC
Created attachment 202192 [details]
WinMerge: search 'nextTo' in chart1.xml

LEFT docx saved in Word
RIGHT docx saved in Writer
Comment 7 Piotr Osada 2025-11-25 20:26:44 UTC
QA:needsComment
Additional findings / clarification

ODS works as expected.

The issue seems to be DOCX (OOXML chart) export mapping: when saving as DOCX, LibreOffice writes in *.DOCX\word\charts\chart1.xml <c:tickLblPos val="nextTo"/> for the category axis, while MS Word/Excel write <c:tickLblPos val="high"/> for the same “Near axis (other side)” placement.
After reopening the DOCX in LO, labels are restored according to the exported OOXML (nextTo), which places them inside/overlapping the plotting area.

This is likely in the OOXML export filter (see [1,5]): the ODF attribute axis-label-position="near-axis-other-side" from *.ODS\Object1\content.xml should map to tickLblPos=high — at least for this case where axis-position="0" and all data values are negative.



----------TL;DR----------
ODS\Object1\content.xml -----> axis-label-position="near-axis-other-side" [3]

LO:
DOCX\word\charts\chart1.xml -> c:tickLblPos val="nextTo" [2]

MSO:
DOCX\word\charts\chart1.xml -> c:tickLblPos val="high" [2]

LO exports: "nextTo"    <-- which is actual [2]
MSO export: "high"      <-- which is expected [2,4]

-------------------------
[1] https://opengrok.libreoffice.org/xref/core/oox/source/export/chartexport.cxx
[2] As can be seen in attachment 202190 [details] that compares file:    
    word/charts/chart1.xml
    Word vs Writer
[3] Example spreadsheet from the attachment 202188 [details] (tdf#167821 Label.ods).
[4] https://c-rex.net/samples/ooxml/e1/part4/OOXML_P4_DOCX_ST_TickLblPos_topic_ID0EEA2RB.html
[5] https://opengrok.libreoffice.org/xref/core/oox/source/export/chartexport.cxx?r=1fa4d0e6c95bddecbcc63bc6622187a8be2ee48d#4399
Comment 8 Piotr Osada 2025-11-25 20:39:41 UTC
(In reply to Piotr Osada from comment #7)
> QA:needsComment

Another TL;DR

DOCX export: chartexport.cxx maps <c:tickLblPos val="nextTo"/> instead of "high", so X-axis labels end up inside the plot area.