Fix static-export legend and colorbar text ignoring theme text_color#86
Open
FarhanAliRaza wants to merge 2 commits into
Open
Fix static-export legend and colorbar text ignoring theme text_color#86FarhanAliRaza wants to merge 2 commits into
FarhanAliRaza wants to merge 2 commits into
Conversation
The SVG and native-PNG exporters painted legend entries, legend titles, and colorbar labels/ticks with the hard-coded light-mode text color (rgba(32,32,32,0.85)), so on dark-themed figures the legend text was nearly invisible in exports while the browser client rendered it with var(--chart-text). Thread the theme-resolved default text color (already used for titles, axis labels, and tick labels) through _legend/_colorbar in _svg.py and _emit_legend/_emit_colorbar in _raster.py. Untouched default: figures without a theme keep the existing light-mode color.
…me-text-color # Conflicts: # python/xy/_raster.py
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Problem
On a dark-themed figure (
xy.theme(text_color="#ffffff", ...)), the browser client renders legend text withvar(--chart-text), but both static exporters painted legend entries, legend titles, and colorbar labels/ticks with the hard-coded light-mode constantrgba(32,32,32,0.85)— so legend text effectively disappears in exported PNG/SVG while remaining visible in the notebook:text_color(visible)Fix
Thread the theme-resolved
default_text(already used for titles, axis labels, and tick labels) through:_svg.py:_legend()and_colorbar()_raster.py:_emit_legend()and_emit_colorbar()Figures without a theme keep the existing light-mode default, byte-for-byte.
Tests
test_svg_legend_text_honors_theme_text_color: themed SVG legend entries + title use the theme color; unthemed keepsrgba(32,32,32,0.85).test_raster_legend_text_honors_theme_text_color: pixel-level check on the native rasterizer — red reserved fortext_color, so red pixels can only come from legend text.pre-commit run --all-files,ruff check/format --check, and both export suites (54 tests) pass.