Issue #503: apply axisTitlePadding to right-side Y axis title#1003
Merged
Conversation
axisTitlePadding opened a gap between the axis title and its tick labels on the left Y axis but not on a right-side (second) Y axis: on the right the padding was spent as dead space on the outer edge of the title, leaving the title jammed against its tick numbers regardless of the padding value. Push the right-side title outward past the tick labels by the padding so it forms a gap mirroring the left side, and shift the bounds origin inward by the same amount so the reserved column width is unchanged. Adds RegressionIssue503Test (asserts the title/tick-label gap scales with padding on both sides via pixel detection) and a TestForIssue503 demo. Co-Authored-By: Claude Opus 4.8 (1M context) <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 #503.
Problem
axisTitlePaddingopens a gap between the axis title and its tick labels on the left Y axis, but not on a right-side (second) Y axis. On the right, the padding was spent as dead space on the outer edge of the title (toward the chart border), leaving the title jammed against its tick numbers no matter how large the padding was set — including via a customTheme extends AbstractBaseThemeoverridinggetAxisTitlePadding(), as in the original report.Root cause
In
AxisTitle.paint(), the left branch bakes the padding into the title bounds width, which the tick labels are then offset by — so the padding lands between the title and the labels. The right (onRight) branch placed the title attick.x + tick.width + textHeightwith no+ padding, so no gap was created; the padding only extended the bounds outward into unused space.Fix
axisTitlePadding, so the padding forms a title↔tick-label gap mirroring the left side.getYAxisWidthHint).Single-file change in
AxisTitle.java; left-axis and single-axis rendering are untouched.Tests
RegressionIssue503Test— renders with title text and tick labels in distinct colors, locates them by pixel, and asserts the title↔tick-label gap grows by ~100px when padding goes 5→105 on both left and right axes. Fails on the old code (right gap stayed fixed), passes now.xchartsuite: 141 tests green.Manual verification
TestForIssue503demo (added) — a customAbstractBaseThemesubclass with a largegetAxisTitlePadding(), one left + one right Y axis. Before: only the left title had a gap; after: both sides respond to the padding in lockstep.🤖 Generated with Claude Code