-
Notifications
You must be signed in to change notification settings - Fork 71
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
[CT-2333] Change font color to maximize contrast against node in lineage graph #408
Comments
@rsanjabi easy to see your point -- thanks for raising it! Three ideas how to solve this from most simple to complex:
Trade-offsOption 2 seems like a reasonable balance between simplicity and complexity. With a healthy dose of optimism, I'm going to label this as See below for a completely untested idea for implementation. Scroll down further for a list of high contrast ratio colors for white text. Ideas for implementing Option 2function getContrastRatio(color1, color2) {
const luminance = (color) => {
const rgb = color.match(/\w\w/g).map((x) => parseInt(x, 16) / 255);
const gammaCorrect = (x) => (x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4);
const r = gammaCorrect(rgb[0]);
const g = gammaCorrect(rgb[1]);
const b = gammaCorrect(rgb[2]);
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
};
const l1 = luminance(color1) + 0.05;
const l2 = luminance(color2) + 0.05;
return Math.max(l1, l2) / Math.min(l1, l2);
}
function chooseTextColor(bgColor) {
const whiteColor = 'ffffff';
const blackColor = '000000';
const contrastWhite = getContrastRatio(whiteColor, bgColor);
const contrastBlack = getContrastRatio(blackColor, bgColor);
return contrastWhite >= contrastBlack ? whiteColor : blackColor;
} const bgColor = '3f87a6';
const textColor = chooseTextColor(bgColor);
console.log(`The chosen text color is #${textColor}`); // The chosen text color is #ffffff List of high-contrast background colors for white textSource: https://www.msfw.com/services/contrastratiocalculator Sorted by color code:
|
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Describe the feature
Within the lineage graph, the font color is always white. Overriding the default node colors to some shades can make it difficult to read the node names.
For example, red and black colors make it easy to see
staging_model1
andint_model
, while gold and light gray with white text make it difficult to readstaging_model2
andmart_model1
Setting the font color relative to the node color should make a wider range of node colors practical.
Describe alternatives you've considered
Creating a favorite list of colors that read well and using that vs. trial and error.
Additional context
The larger the graph, the smaller the nodes tend to be, and the more that contrast is helpful.
Who will this benefit?
Are you interested in contributing this feature?
Probably not.
The text was updated successfully, but these errors were encountered: