Better text color selection for a given background#820
Merged
RomRider merged 1 commit intoRomRider:devfrom Aug 20, 2025
Merged
Conversation
Contributor
|
I am updating old request onto a copy of this repo, as this repo seems abandoned. I like the idea/layout but your suggested changes have no effect with my repo. I am using the ootb/default HA theme |
Owner
|
Thanks ! |
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 20, 2025
## 2.2.0-dev.2 (2025-08-20) * docs: Fix typos and improve grammar in README.md (#698) ([6655949](6655949)), closes [#698](#698) * docs: Updated install instructions ([37f3fa2](37f3fa2)) * feat(series): Extend `stroke_dash` to support an array for more complex dashing patterns (#902) ([cafbcec](cafbcec)), closes [#902](#902) * Fix: Text color selection for given background now takes into account human perception. (#820) ([f09756f](f09756f)), closes [#820](#820) * chore(deps): Update release dependencies and some outdated packages ([07b901a](07b901a))
|
🎉 This PR is included in version 2.2.0-dev.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 20, 2025
## [2.2.0](v2.1.2...v2.2.0) (2025-08-20) ### Features * Display the card version on the card (useful for debugging) ([ac800c5](ac800c5)) * **series:** Add option to hide null or zero values in the header ([#544](#544)) ([baf2066](baf2066)), closes [#543](#543) * **series:** Extend `stroke_dash` to support an array for more complex dashing patterns ([#902](#902)) ([cafbcec](cafbcec)) * Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736) ### Bug Fixes * graph rendering too wide when heading title is too long ([#812](#812)) ([094280d](094280d)) * Text color selection for given background now takes into account human perception. ([#820](#820)) ([f09756f](f09756f)) ### Documentation * Fix typos and improve grammar in README.md ([#698](#698)) ([6655949](6655949)) * Updated install instructions ([37f3fa2](37f3fa2))
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 20, 2025
## [2.2.0](v2.1.2...v2.2.0) (2025-08-20) ### Features * Display the card version on the card (useful for debugging) ([ac800c5](ac800c5)) * **series:** Add option to hide null or zero values in the header ([#544](#544)) ([baf2066](baf2066)), closes [#543](#543) * **series:** Extend `stroke_dash` to support an array for more complex dashing patterns ([#902](#902)) ([cafbcec](cafbcec)) * Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736) ### Bug Fixes * graph rendering too wide when heading title is too long ([#812](#812)) ([094280d](094280d)) * Text color selection for given background now takes into account human perception. ([#820](#820)) ([f09756f](f09756f)) ### Documentation * Fix typos and improve grammar in README.md ([#698](#698)) ([6655949](6655949)) * Updated install instructions ([37f3fa2](37f3fa2))
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 20, 2025
## [2.2.0](v2.1.2...v2.2.0) (2025-08-20) ### Features * Display the card version on the card (useful for debugging) ([ac800c5](ac800c5)) * **series:** Add option to hide null or zero values in the header ([#544](#544)) ([baf2066](baf2066)), closes [#543](#543) * **series:** Extend `stroke_dash` to support an array for more complex dashing patterns ([#902](#902)) ([cafbcec](cafbcec)) * Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736) ### Bug Fixes * graph rendering too wide when heading title is too long ([#812](#812)) ([094280d](094280d)) * Text color selection for given background now takes into account human perception. ([#820](#820)) ([f09756f](f09756f)) ### Documentation * Fix typos and improve grammar in README.md ([#698](#698)) ([6655949](6655949)) * Updated install instructions ([37f3fa2](37f3fa2))
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.
Currently, apexcharts selects text color inadequately. It can select white text for quiet bright background.


The problem is that
computeTextColor()function uses linearcolorObj.getLuminance(), which is not how human percepts color.TinyColor has
isLight()/isDark()methods, which work in gamma space, and my experiments indicate it works better for this purpose.Here is the comparison (before/after):
The color of the graph is
#BAACC7which has linear luminance of about 0.44. This is less than 0.5, thus master version of apex-charts selects white text color. However, as you can probably see, black text color is much more readable.