Skip to content

Opt-in gradient fills for category and horizontal bars - #1037

Open
mvanhorn wants to merge 1 commit into
knowm:developfrom
mvanhorn:fix/730-xchart-bar-gradient-fill
Open

mvanhorn wants to merge 1 commit into
knowm:developfrom
mvanhorn:fix/730-xchart-bar-gradient-fill

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Category bar charts and horizontal bar charts paint each bar, and the matching legend swatch, with one flat series fill color. A caller has no styler option that fades that color from the bar base to a brighter color at the value.

Verification

The xchart module test-compile finished and the reactor reported BUILD SUCCESS.

Summary

CategoryStyler and HorizontalBarStyler add setBarFillGradientEnabled, initialized false so existing charts keep the flat fill. When the flag is on, PlotContent_Category and PlotContent_HorizontalBar fill each bar with a non-cyclic GradientPaint from the series fill at the segment base to fill.brighter() at the value end; negative bars reverse those ends, coincident endpoints stay flat, and the Graphics2D paint from before the gradient is restored. Legend_Marker uses that upward positive-bar gradient only for a CategorySeries rendered as Bar, and Legend_HorizontalBar uses a left-to-right positive-bar gradient; every other swatch stays a flat fill. BarChart14 turns the option on for positive and negative category bars, and BarFillGradientTest checks rendered pixels for direction, stacking, clipping, log axes, legends, non-bar series, and alpha.

Fixes #730

CategoryStyler and HorizontalBarStyler add setBarFillGradientEnabled,
initialized false so existing charts keep the flat fill. When the flag
is on, PlotContent_Category and PlotContent_HorizontalBar fill each bar
with a non-cyclic GradientPaint from the series fill at the segment base
to fill.brighter() at the value end; negative bars reverse those ends,
coincident endpoints stay flat, and the Graphics2D paint from before the
gradient is restored. Legend_Marker uses that upward positive-bar
gradient only for a CategorySeries rendered as Bar, and
Legend_HorizontalBar uses a left-to-right positive-bar gradient; every
other swatch stays a flat fill. BarChart14 turns the option on for
positive and negative category bars, and BarFillGradientTest checks
rendered pixels for direction, stacking, clipping, log axes, legends,
non-bar series, and alpha.

Fixes knowm#730
@mvanhorn mvanhorn mentioned this pull request Oct 13, 2026

This branch has not been deployed

No deployments
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.

Gradient fill?

1 participant