Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better text color selection for a given background #820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kosumosu
Copy link

Currently, apexcharts selects text color inadequately. It can select white text for quiet bright background.
The problem is that computeTextColor() function uses linear colorObj.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):
apex-charts-bg-color-BAACC7-is-unreadable-big
apex-charts-bg-color-BAACC7-is-unreadable-big-fixed

The color of the graph is #BAACC7 which 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.

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.

1 participant