Skip to content

Issue #503: apply axisTitlePadding to right-side Y axis title#1003

Merged
timmolter merged 1 commit into
developfrom
issue-503-axis-title-padding-right-y-axis
Jul 16, 2026
Merged

Issue #503: apply axisTitlePadding to right-side Y axis title#1003
timmolter merged 1 commit into
developfrom
issue-503-axis-title-padding-right-y-axis

Conversation

@timmolter

Copy link
Copy Markdown
Member

Fixes #503.

Problem

axisTitlePadding opens 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 custom Theme extends AbstractBaseTheme overriding getAxisTitlePadding(), 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 at tick.x + tick.width + textHeight with no + padding, so no gap was created; the padding only extended the bounds outward into unused space.

Fix

  • Push the right-side title outward past the tick labels by axisTitlePadding, so the padding forms a title↔tick-label gap mirroring the left side.
  • Shift the right-side bounds origin inward by the same amount, keeping the reserved column width unchanged (no change to 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.
  • Full xchart suite: 141 tests green.

Manual verification

TestForIssue503 demo (added) — a custom AbstractBaseTheme subclass with a large getAxisTitlePadding(), 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

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>
@timmolter
timmolter merged commit c8efb8f into develop Jul 16, 2026
1 check passed
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.

Axis Title Padding in AbstractBaseTheme does not apply to second Y Axis

1 participant