Allow bar chart data labels to be positioned outside the bars (#500)#981
Open
timmolter wants to merge 1 commit into
Open
Allow bar chart data labels to be positioned outside the bars (#500)#981timmolter wants to merge 1 commit into
timmolter wants to merge 1 commit into
Conversation
325de34 to
9d1b855
Compare
Restores the ability (present in 3.6.1) to place bar chart value labels outside the bars, which was lost when the configurable labelsPosition was added and clamped to [0, 1] (inside only). - CategoryStyler/HorizontalBarStyler: relax the labelsPosition cap so values greater than 1 are allowed; document the semantics. - PlotContent_Category/PlotContent_HorizontalBar: for labelsPosition > 1, draw the label outside the bar at a fixed pixel gap that does not scale with the bar's size: gap = (labelsPosition - 1) * 100 pixels. The inside [0, 1] behavior (fraction of the bar) is unchanged. - Compute the automatic label font color against the plot background, not the bar fill, when the label is drawn outside the bar so it stays legible (also fixes stack-sum labels). - AxisPair: reserve axis headroom automatically when labels are drawn outside so they are not clipped at the plot edge. - Demos: show outside labels in BarChart04 and HorizontalBarChart01, and add TestForIssue500 / TestForIssue500_HorizontalBar. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9d1b855 to
995255f
Compare
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 #500.
Problem
Before 3.6.4, bar chart value labels could be drawn outside (on top of) the bars. That ability was lost when the configurable
labelsPositionwas introduced (#402) and clamped to[0, 1], which only allows placement inside the bar (baseline → top). Users asked for the "labels on top" behavior back.Changes
CategoryStyler/HorizontalBarStyler: relax thelabelsPositionupper cap so values greater than1are allowed (still rejects< 0); javadoc documents the new semantics.PlotContent_Category/PlotContent_HorizontalBar: forlabelsPosition > 1, draw the label outside the bar at a fixed pixel gap that does not scale with the bar's size —gap = (labelsPosition - 1) * 100pixels (e.g.1.1→ 10px). The inside[0, 1]behavior (a fraction of the bar) is unchanged. Earlier the outside distance scaled with bar height, so taller bars pushed their labels much farther out — fixed here.AxisPair: automatically reserve axis headroom when labels are drawn outside, so they are not clipped at the plot edge (no need to set manual axis min/max).Demos
BarChart04andHorizontalBarChart01.TestForIssue500andTestForIssue500_HorizontalBarstandalone issue charts (positive and negative values).Testing
🤖 Generated with Claude Code