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

Update labelTextColor to accept functions the same way that colors does #2679

Open
bgould132 opened this issue Dec 20, 2024 · 0 comments
Open

Comments

@bgould132
Copy link

bgould132 commented Dec 20, 2024

Current SItuation

At present, labelTextColor accepts either a single color (either specified or from theme), or a from: colors modifiers: value that scales it lighter, darker, or more/less opaque relative to the background color.

However, a growing number of websites are required to comply with Web Content Accessibility Guidelines (WCAG) standards, which include requirements for adequate contrast between label text and background colors. Light colors need dark labels, and dark colors need light labels. Currently, labelTextColor does not support a solution to meet this WCAG standard. Instead, designers and developers need to ensure all colors have sufficient contrast to a single label color, limiting the range of colors that can be used for a given chart which may require dozens of different colors.

Suggestion

colors accepts a function in the form of, e.g. bar => dataColors[bar.id], enabling each value to be separately colored.
labelTextColor should be able to accept a similar function. The current functionality does not correctly register values of bar passed into labelTextColor.

Ultimately, it should be possible to use another library like chroma.js to evaluate the color of a background, determine whether labelTextColor should be white or black for a given background to meet accessibility requirements, and set the color for that label independently of the other labels.

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

No branches or pull requests

1 participant