Fix x-axis line hidden by plot area with OutsideS legend - #1025
Open
timmolter wants to merge 1 commit into
Open
Conversation
Axis_X.preparePaint() subtracted the OutsideS legend height from the top of the x-axis bounds even though Axis_Y had already reserved that space when computing its height (whose bottom defines the plot bottom), so the x-axis bounds started a legend-height inside the plot area. The bounds height did not subtract it, so only the top edge was wrong — harmless while the axis line was positioned bottom-up from the painted tick label geometry, but since the line and tick marks are anchored to the top of the x-axis bounds (#1023) they were drawn inside the plot, which is painted afterwards and covered them. Move the legend height subtraction from the bounds top to the bounds height, keeping the bottom edge unchanged so the bottom-anchored axis title and tick label positioning is unaffected. Fixes #1024 Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Fixes #1024.
Root cause
Axis_X.preparePaint()subtracted theOutsideSlegend height from the top of the x-axis bounds even thoughAxis_Y.preparePaint()had already reserved that space when computing the y-axis height — and the y-axis bottom is what defines the plot bottom. With a visibleOutsideSlegend, the x-axis bounds therefore started a legend-height inside the plot area. The bounds height did not subtract the legend, so only the top edge was wrong.This double-subtraction dates back to at least 3.8.8 but was latent: the axis line used to be positioned bottom-up from the painted tick label geometry. Since #1023 (4.0.4) the x-axis line and tick marks are anchored to the top of the x-axis bounds — placing them inside the plot area, which is painted afterwards and covers them. Measured on a 400×400 chart: plot bottom 351.7, correct line y 355.7, actual bounds top 337.4.
Fix
Move the legend height subtraction from the bounds' y-offset to the bounds' height. The bottom edge is unchanged (
chartHeight - chartPadding - legendHeight, same as before), so the bottom-anchored x-axis title and tick label positioning is unaffected; only the line/marks anchor moves back toplotBottom + plotMargin.Tests / demo
AxisLinePlotMarginTestgains anOutsideS-legend variant of the existing pixel-scanning margin check (headless, noXChartPanel). It fails without the fix ("x-axis line must be found below the plot") and passes with it.TestForIssue1024demo added, reproducing the reported chart (grey plot, white grid lines,OutsideShorizontal legend, German-locale labels).🤖 Generated with Claude Code