Skip to content

Fix x-axis line hidden by plot area with OutsideS legend - #1025

Open
timmolter wants to merge 1 commit into
developfrom
issue-1024-xaxis-line-outsides-legend
Open

Fix x-axis line hidden by plot area with OutsideS legend#1025
timmolter wants to merge 1 commit into
developfrom
issue-1024-xaxis-line-outsides-legend

Conversation

@timmolter

Copy link
Copy Markdown
Member

Fixes #1024.

Root cause

Axis_X.preparePaint() subtracted the OutsideS legend height from the top of the x-axis bounds even though Axis_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 visible OutsideS legend, 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 to plotBottom + plotMargin.

Tests / demo

  • AxisLinePlotMarginTest gains an OutsideS-legend variant of the existing pixel-scanning margin check (headless, no XChartPanel). It fails without the fix ("x-axis line must be found below the plot") and passes with it.
  • TestForIssue1024 demo added, reproducing the reported chart (grey plot, white grid lines, OutsideS horizontal legend, German-locale labels).
  • Full xchart suite: 169 tests, 0 failures.
before (4.0.4) after
x-axis line hidden under plot line + tick marks at plotMargin below plot, as in 3.8.8

🤖 Generated with Claude Code

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>
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.

X-Axis Line not visible

1 participant