Skip to content

fix: apply alpha to gradient palette colors in data_color() - #892

Merged
rich-iannone merged 1 commit into
posit-dev:mainfrom
taekop:fix/data-color-gradient-alpha
Oct 2, 2026
Merged

rich-iannone merged 1 commit into
posit-dev:mainfrom
taekop:fix/data-color-gradient-alpha

Conversation

@taekop

@taekop taekop commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Summary

GT.data_color(alpha=...) had no effect on cells colored by a gradient palette (the default numeric/factor path). GradientPalette interpolates colors using RGBColor tuples (tuple[int, int, int]) internally, which have no alpha channel, so the alpha= value baked into palette before interpolation was lost by the time each color was assigned to a cell. na_color was unaffected since it goes through _html_color(alpha=...) separately.

This reapplies alpha= to the interpolated colors right after color_scale_fn runs, skipping None entries (which stand in for NA values and get na_color afterward).

Related GitHub Issues and PRs

Checklist

GradientPalette interpolates using RGB tuples internally, which have no
alpha channel, so the alpha= value baked into the palette was lost by
the time colors were assigned to cells. Reapply alpha to the
interpolated colors after the gradient scale runs.
@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.34%. Comparing base (f870830) to head (12e0f4a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #892   +/-   ##
=======================================
  Coverage   98.33%   98.34%           
=======================================
  Files          52       52           
  Lines        8310     8316    +6     
=======================================
+ Hits         8172     8178    +6     
  Misses        138      138           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rich-iannone
rich-iannone merged commit b57dd23 into posit-dev:main Oct 2, 2026
15 checks 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.

Alpha value gets hidden by data_color()

2 participants