Skip to content

fix(xlsx): seat a bar chart's Excel category label sheet-space-correctly - #1762

Open
developer0hye wants to merge 2 commits into
mainfrom
fix/xlsx-bar-category-label-x
Open

developer0hye wants to merge 2 commits into
mainfrom
fix/xlsx-bar-category-label-x

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

Summary

Excel right-aligns a worksheet horizontal-bar chart's category label a further EXCEL_BAR_CATEGORY_LABEL_X_SHIFT_EM * size_pt sheet points right of the PowerPoint-calibrated box chart_category_label_box_w shares across every chart host. Measured by patching tests/fixtures/xlsx/issue_1181_fit_to_height.xlsx's category-axis size to 8, 10, 14 and 18pt (assets/validation/issue-1620/category-size-probe.json, native Excel via --backend office) and comparing fresh native exports against the shared box.

The correction is added to plot.dx inside the fitted sheet's own #scale(print_scale) wrapper (write_placed_sheet_anchor in typst_gen.rs), so it has to be calibrated in sheet points, not printed points. An earlier draft of this fix (from a prior session on this branch) calibrated the constant directly against mutool-traced printed points (0.0262), which under-applies by exactly this sheet's own 0.78 print scale once rendered — converting with that constant and remeasuring showed the applied page effect was 0.2044pt at 10pt, not the 0.2610pt printed gap it was meant to close (0.262 x 0.78 = 0.2044, confirmed to 4 significant figures against a fresh before/after isolation diff). Dividing each printed measurement by 0.78 before deriving the ratio gives the corrected constant, 0.0336. Full derivation and the arithmetic check in assets/validation/issue-1620/README.md.

After this fix, the five affected category labels (other, from savings, financial aid, other expenses, discretionary) land within 0.008 printed points of native — essentially exact — down from -0.254 to -0.266pt before it. (#1620's own filed numbers were -0.729 to -0.741pt against an older main; commit 082fa901, #1272, merged one day after this issue was filed, independently closed most of that gap by pulling an overrunning c:manualLayout plot rectangle back inside its chart area. Both corrections are real and independently measured — see the README for the full reconciliation.)

Comparing office2pdf's own output before vs. after this fix in isolation (--fine-shift 0.01): exactly the 11 category labels across both bar charts move, each dx +0.26pt, dy +0.00pt; rectangle census is bit-identical (738/738, 0 geometry deviations). Nothing else on the page moves.

While auditing this fixture's full page 2 for the required visual-evidence contract, three unrelated residuals were found and filed separately rather than bundled here: #1759 (bar-fill vertical seat/width), #1760 (a differ line-grouping classification artifact, not a converter defect), #1761 (a repeated %INC header's horizontal position). #1757 (a form-control label row's -2.16pt outlier) was already filed during an earlier pass of this same audit.

File submission policy

Related issue

Related: #1620

Testing

  • Red/green: an_excel_bar_category_label_sits_the_measured_offset_right_of_powerpoints (8pt and 18pt, sheet-space-converted literals) and an_excel_bar_category_label_with_no_declared_size_keeps_powerpoints_box (the no-native-probe guard branch, mirroring excel_category_label_y_shift_pt) fail without the fix.
  • cargo test --locked -p office2pdf --lib: 3091 passed.
  • cargo test --locked --workspace: all suites green.
  • cargo fmt --all --check: clean.
  • compare_text_layer.py on a fresh native GT vs. this fix's output: unchanged from before this fix (2 extra spaces, a pre-existing reading-order difference, not touched by this change).
  • Required delegated read-only documentation freshness audit: PASS (three passes; the second and third caught a numeric reconciliation gap and the sheet-space/printed-space unit bug this PR now fixes).
  • Probe spec, native measurements, and the sheet-space-vs-printed-space derivation: validation.

Visual impact

  • No rendered PDF change
  • Rendered PDF change or visual evidence added

Visual audit

Visual comparison

GT Before After
GT Before After

Required inspection

  • Rendered all evidence at 150 DPI or higher
  • Stored progressive JPEG quality 86 assets with metadata stripped
  • Used Codex/Claude vision to inspect the full GT/output pages, diff, and matched crops
  • Inspected matched region crops at full resolution
  • Ran compare_layout.py --audit --fine-shift PT and dispositioned every fine/large text-instance shift, rectangle geometry deviation, painted-text visibility mismatch, and visible-fill occlusion
  • Ran compare_render.py --cluster-report PATH --strict-clusters and dispositioned every material 5% fuzz diff cluster by explicit ID
  • Inventoried hairlines and border dash styles
  • Inventoried font weight, italic, and underline emphasis

Deviation audit

Check Result
Page count/order Matches GT
Element presence Matches GT
Position/size Remaining: #1631, #1621, #1622, #1623, #1721, #1757, #1759, #1761; the two bar charts' category-label horizontal position is fixed by this PR (#1620).
Rotation/flip No deviation observed
Fill Remaining: #1632, #1759
Stroke/border No deviation observed
Shape outline geometry No deviation observed
Text content No deviation observed (a pre-existing 2-space/reading-order text-layer difference is unchanged before and after this fix; not touched by this change)
Font family/weight/style Matches GT
Text color Matches GT
Alignment Remaining: #1631, #1621, #1622, #1623, #1719, #1761; the category-label right-alignment box position is fixed by this PR (#1620).
Line/paragraph spacing Remaining: #1719, #1760
Clipping/overflow No deviation observed

Checklist

  • Commits include a Signed-off-by line
  • PR scope contains one root cause
  • Remaining converter or harness deviations each reference an open issue

🤖 Generated with Claude Code

developer0hye and others added 2 commits September 17, 2026 01:13
Excel keeps a narrower clearance than the PowerPoint-calibrated box
chart_category_label_box_w shares across hosts, right-aligning a
worksheet bar chart's category label a further
EXCEL_BAR_CATEGORY_LABEL_X_SHIFT_EM * size_pt sheet points right of it.

Measured on tests/fixtures/xlsx/issue_1181_fit_to_height.xlsx (#1620) by
patching only the category-axis size to 8, 10, 14 and 18pt and comparing
fresh native Excel exports against the shared box. The correction is
added inside the fitted sheet's own #scale(print_scale) wrapper, so it
must be calibrated in sheet points, not printed points; dividing each
printed native measurement by this sheet's 0.78 print scale before
deriving the ratio gives 0.0336, not the 0.0262 a printed-point
calibration would suggest (which under-applies by exactly that scale
once rendered). After this fix the five affected category labels land
within 0.008pt of native, down from -0.254 to -0.266pt before it.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
gt.jpg/before.jpg/after.jpg (300 DPI category-label crop), layout-audit.json,
and a fully dispositioned render-clusters-page-2.json for the bar-chart
category-label fix. 380 of 394 material render-diff clusters on this page
reuse the committed issue-1564 baseline's dispositions by exact bbox match;
the other 14 are freshly classified to #1632, #1757, #1759, and #1761 (the
last two newly filed during this audit).

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
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