Skip to content

Add BoxStyler.setBoxWidthFraction to control box plot width (#816)#995

Merged
timmolter merged 1 commit into
developfrom
issue-816-boxplot-width
Jul 6, 2026
Merged

Add BoxStyler.setBoxWidthFraction to control box plot width (#816)#995
timmolter merged 1 commit into
developfrom
issue-816-boxplot-width

Conversation

@timmolter

Copy link
Copy Markdown
Member

Closes #816.

Problem

Box widths in a BoxChart were hard-wired to the plot margin (2 * xLeftMargin) in PlotContent_Box. That produces a thin, fixed width that is independent of the number of series and offers no way to make boxes wider or narrower.

Change

Add BoxStyler#setBoxWidthFraction(double) / getBoxWidthFraction():

  • A value in (0, 1] sizes each box relative to the horizontal slot available to it (the per-series slot). 1.0 makes adjacent boxes touch.
  • <= 0 (the default of -1) keeps the legacy width, so existing charts render identically.

PlotContent_Box now derives a single halfBoxWidth (from the fraction, or the legacy margin when unset) and uses it for the box rectangle, median line, whisker caps, and tooltip bounds. Box center positioning is unchanged.

Tests / demo

  • BoxChartTest: default value, setter round-trip, and render-doesn't-throw with a fraction set.
  • standalone/issues/TestForIssue816: default vs. 0.6 side by side (headless-safe getChart(double)).
  • Full xchart suite: 125 pass. Pixel measurement confirms width scales monotonically with the fraction.

🤖 Generated with Claude Code

Box widths were hard-wired to the plot margin (2 * xLeftMargin) in
PlotContent_Box, giving a thin, fixed width that ignored the number of
series and offered no user control.

Add BoxStyler#setBoxWidthFraction(double): a value in (0, 1] sizes each
box relative to the horizontal slot available to it; <= 0 (the default
of -1) keeps the legacy width, so existing charts are unaffected. The
painter derives a single halfBoxWidth used for the box, median line,
whisker caps, and tooltip bounds; center positioning is unchanged.

Adds BoxChartTest coverage (default, round-trip, render) and a
standalone TestForIssue816 demo showing default vs. 0.6 side by side.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@timmolter timmolter merged commit 62e4f39 into develop Jul 6, 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.

Boxplot width

1 participant