fix(xlsx): seat a bar chart's Excel category label sheet-space-correctly - #1762
Open
developer0hye wants to merge 2 commits into
Open
developer0hye wants to merge 2 commits into
developer0hye wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Excel right-aligns a worksheet horizontal-bar chart's category label a further
EXCEL_BAR_CATEGORY_LABEL_X_SHIFT_EM * size_ptsheet points right of the PowerPoint-calibrated boxchart_category_label_box_wshares across every chart host. Measured by patchingtests/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.dxinside the fitted sheet's own#scale(print_scale)wrapper (write_placed_sheet_anchorintypst_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 againstmutool-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 inassets/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 oldermain; commit082fa901, #1272, merged one day after this issue was filed, independently closed most of that gap by pulling an overrunningc:manualLayoutplot 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, eachdx +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
%INCheader'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
tests/fixtures/xlsx/issue_1181_fit_to_height.xlsx) and its native-export evidence derive from the existing public Gift Budget and Tracker1.xlsx misc issues #982 attachment via XLSX: fitToHeight is not modelled, so a sheet Excel fits on one A3 page prints on two #1181's own tracked fixture; no new organizational file is submitted.Related issue
Related: #1620
Testing
an_excel_bar_category_label_sits_the_measured_offset_right_of_powerpoints(8pt and 18pt, sheet-space-converted literals) andan_excel_bar_category_label_with_no_declared_size_keeps_powerpoints_box(the no-native-probe guard branch, mirroringexcel_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.pyon 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).Visual impact
Visual audit
tests/fixtures/xlsx/issue_1181_fit_to_height.xlsx(unmodified; SHA-2562b4a2d8dceda58758593c88409875efbda05780559154c02bd13fef4f7a1c65b)fixassets/bugfixes/issue-1620/layout-audit.jsonassets/bugfixes/issue-1620/render-clusters-page-2.jsongt.jpg/before.jpg/after.jpg, both bar charts' label column) shows no visible difference at this scale — the fix moves text by 0.26 printed points, under one 300-DPI pixel — consistent with the near-zero measured residual. All 394 material render-diff clusters on the page were classified: 380 reused, by exact bbox match, from the committedassets/bugfixes/issue-1564/render-clusters-page-2.jsonbaseline (185 to XLSX: right-aligned cells on the fitted budget sheet land 0.9pt left to 2.2pt right of Excel by number format #1631's number-format-dependent cell dx, 137 to XLSX: fitted worksheet cell fills sit one sheet point above Excel's #1632's one-sheet-point-high fills, 43 to XLSX: large left-aligned Cambria title starts 1.255pt left of native #1623's title dx, 16 to XLSX: a 14-15pt bottom-aligned cell in a 19.5pt fixed row is centred as a tight row where Excel bottom-seats it #1721's tight-row centring); the remaining 14 were freshly inspected this session. Nine are thin (0.72pt-high) bar-fill edge strips at the income and expense charts' own plot value-zero columns (x=152.64 and x=419.28) — cropped and viewed as green rectangle edges sitting a fraction of a point off native, filed as XLSX: horizontal bar-chart value-bar fills sit ~0.544pt above native, widest bar 11pt narrow #1759. One is the "Monthly Scroll" spinner's own selector band containing the bold white "JAN" label, in the same form-control region XLSX: a form-control label row sits 2.16pt above Excel where the rest of the fitted sheet sits ~0.6-0.8pt off #1757 already tracks. Three are a repeated "%INC" column header sitting +0.39pt right of native, a distinct sign and magnitude from the general fitted-text band (XLSX: fitted worksheet text keeps the physical margin origin while its paint layer snaps to Excel's sheet-space origin #1719, -0.475pt) and the number-format cell family (XLSX: right-aligned cells on the fitted budget sheet land 0.9pt left to 2.2pt right of Excel by number format #1631) — filed as XLSX: repeated %INC column-header text sits 0.39pt right of native #1761. None of the 394 clusters fall in the category-label region this fix touches; the five affected labels' own pixel difference at 10pt declared size is below the 20pt² material-cluster floor after this fix.assets/bugfixes/issue-1620/gt.jpgassets/bugfixes/issue-1620/before.jpgassets/bugfixes/issue-1620/after.jpgassets/bugfixes/issue-1620/compare.jpg(filed with the original issue)Visual comparison
Required inspection
Deviation audit
Checklist
Signed-off-byline🤖 Generated with Claude Code