Repository navigation
fix(preview): lay out chart plot areas and line labels as LibreOffice does - #482
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
baseballyama
force-pushed
the
fix/preview-combo-plot-area
branch
from
October 25, 2026 05:36
0177f5d to
e1b1f45
Compare
… does The plot area kept a fixed 8 px margin and an 18 px legend strip, so a chart with a bottom legend drew its plot about 30 px taller than LibreOffice, and line labels above a point sat on the marker. Use LibreOffice's chart2 rules: 2% of the frame per side, a bottom legend box 1.85 mm from the edge and from the plot, half a value-label line above the plot, a category-label row sized to its font, and line labels 1 mm clear of the marker.
The legend band and the half line above the plot followed a newer LibreOffice than the fidelity reference and drew three sample slides further from it.
baseballyama
force-pushed
the
fix/preview-combo-plot-area
branch
from
October 25, 2026 06:02
e1b1f45 to
9d406d3
Compare
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
The preview drew cartesian charts with a taller plot area than LibreOffice and put line labels on top of their markers, so labels that collide in the real chart (a bar's
inEndvalue label against a secondary-axis line label) looked separate in the preview. The automatic layout now follows LibreOffice's chart2 rules.Motivation
A deck generator reviews preview PNGs to fix overlapping chart labels. On a combo chart (columns + a secondary-axis line, bottom legend, 12 pt labels) LibreOffice shows
13,150/51.0%,14,020/52.0%and15,640/53.4%overlapping; the preview showed none of them.Measured plot areas (axis spines, 1280 px wide) for four charts of the same deck:
Line label glyph rows above a 7 pt marker with a 12 pt label: LibreOffice 349–359, before 357–368 (on the marker), after 349–359.
The inset comes from LibreOffice's source (
chart2/source/view/main/ChartView.cxx):constPageLayoutDistancePercentage = 0.02applied to each side of the diagram space.The "after" column above is from the first revision, which also reserved a bottom legend box with 1.85 mm gaps (
VLegend.cxx) and half a value-label line above the plot. Those two rules come from a newer LibreOffice than the fidelity gate's reference (24.2): against it they moved the legend and plot top away and regressed three sample slides (31-2, 37-1, 40-1). They are dropped; the legend strip and plot top stay as onmain. With the remaining changes every slide is within the gate's tolerance (31-2 0.8371, 37-1 0.8997, 40-1 0.7828 against the CI ground truth).The reference desktop app could not be used as ground truth here: its scripted PDF export timed out on this machine, so the numbers are LibreOffice only.
Changes
t/bkeep their line box 1 mm clear of the marker (was a fixed 5 px / 13 px offset from the point).Testing
test/preview-chart-auto-layout.test.tscovers the insets, the font-sized category row, and line label clearance.preview-chart-axis-controls,preview-chart-fill-opacityandpreview-chart-inner-layoutto the new layout.npx vitest run test/preview-passes (1155 tests).Breaking changes
None in the API. Chart previews render with a slightly smaller plot area.
Checklist
flagged it above.