Add BoxStyler.setBoxWidthFraction to control box plot width (#816)#995
Merged
Conversation
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>
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.
Closes #816.
Problem
Box widths in a
BoxChartwere hard-wired to the plot margin (2 * xLeftMargin) inPlotContent_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():(0, 1]sizes each box relative to the horizontal slot available to it (the per-series slot).1.0makes adjacent boxes touch.<= 0(the default of-1) keeps the legacy width, so existing charts render identically.PlotContent_Boxnow derives a singlehalfBoxWidth(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.6side by side (headless-safegetChart(double)).xchartsuite: 125 pass. Pixel measurement confirms width scales monotonically with the fraction.🤖 Generated with Claude Code