-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[TSVB] fix text color when using custom background color #60261
Conversation
When the user apply a background color manually from the UI, this commit adapt the current colors to have a better contrast with the choosed background color irrespective of the used dark/light theme
Pinging @elastic/kibana-app (Team:KibanaApp) |
bgColor: string, | ||
lightFgColor: string, | ||
darkFgColor: string, | ||
ratio = 4.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AA contrast is actually 4.5
not 4.4
. And this contrast is expected to be attained for text. However, for graphics like axis lines and pure fill colors without text, only a 3.0
contrast level needs to be met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I think I've found cases where I cannot reach a 4.5 value with a grey scale foreground color, but maybe I'm completely wrong about that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update here f490b91
if (relLum <= 0.0031308) { | ||
return relLum * 12.92; | ||
} else { | ||
return (1.0 + 0.055) * Math.pow(relLum, 1.0 / 2.4) - 0.055; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you are re-writing the WCAG's luminance and contrast calculator in this file. My thoughts are:
A. This would be good to be pulled into a service instead so it doesn't have to be re-written by other chart types or plugins.
B. EUI does export a calculateContrast
color service
C. ChromaJS is a dependency and they have a .contrast
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good candidate for the “charts” plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cchaos I'm not rewriting the luminance here, I'm inverting the luminance formula to get the lightness to use with the gray color.
This for sure will be part of elastic-charts, I'm currently applying this here because it needs to be released on a patch release and we can't upgrade the chart library in a patch release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can replace computeContrast
with the contrast method of color
We don't have chromajs as a dependency in Kibana right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated here: 07f437a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ for moving this to elastic-charts later on
.tvbVisTimeSeriesDark { | ||
.echReactiveChart_unavailable { | ||
color: #DFE5EF; | ||
} | ||
.echLegendItem { | ||
color: #DFE5EF; | ||
} | ||
} | ||
.tvbVisTimeSeriesLight { | ||
.echReactiveChart_unavailable { | ||
color: #343741; | ||
} | ||
.echLegendItem { | ||
color: #343741; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see this becoming an ever-growing list of overrides and we highly suggest not applying straight hex values when they come from the EUI palette/theme. We need to figure out a more extensible approach like possibly adding these to the Chart theme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be moved to elastic-charts for sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Chrome Linux, seems to work with different combinations of darkmode on/off and background colors. One minor nitpick about test names, otherwise this looks good to me.
import { getTheme } from './theme'; | ||
import { LIGHT_THEME, DARK_THEME } from '@elastic/charts'; | ||
|
||
describe('src/legacy/core_plugins/vis_type_timeseries/public/visualizations/views/timeseries/utils/theme.ts', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a proper test name here like "TSVB theme" (even if the rest of TSVB does that weirdly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated here 3bd5f54
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* master: (30 commits) [TSVB] fix text color when using custom background color (elastic#60261) Fix import to timefilter from in TSVB (elastic#60296) [NP] Get rid of usage redirectWhenMissing service (elastic#59777) [SIEM] Fix Timeline footer styling (elastic#59587) [ML] Fixes to error handling for analytics jobs and file data viz (elastic#60249) Give better stack traces for Unhandled Promise Rejection warnings (elastic#60235) resolves elastic#58905 (elastic#60120) Added variables button for text fields in Pagerduty component. (elastic#60189) adds test that action vars are rendered for alert action parms (elastic#60310) Closes 59786 by removing the update toast (elastic#60172) [EPM] Packages list tabs (elastic#60167) Added message variables button for Webhook body form field (elastic#60174) Revert "adds new test (elastic#60064)" [Maps] move MapSavedObject type out of telemetry (elastic#60127) [Reporting] Fix error handling for job handler in route (elastic#60161) [Endpoint] TEST: verify alerts page header says 'Alerts' (elastic#60206) EMT-248: implement ack resource to accept event payload to acknowledge agent actions (elastic#60218) Migrate dual validated range (elastic#59689) Embeddable triggers (elastic#58440) [Endpoint] Sample data generator CLI script (elastic#59952) ...
When the user apply a background color manually from the UI, this commit adapt the current colors to have a better contrast with the chosen background color irrespective of the used dark/light theme
When the user apply a background color manually from the UI, this commit adapt the current colors to have a better contrast with the chosen background color irrespective of the used dark/light theme
* master: (51 commits) do not update cell background if is label cell (elastic#60308) FTR configurable test users (elastic#52431) [Reporting] Wholesale moves client to newest-platform (elastic#58945) [Ingest] Support `show_user` package registry flag (elastic#60338) [SIEM] Adds 'Closes one signal when more than one opened signals are selected' test again (elastic#60380) [SIEM][Detections Engine] - Add rule markdown field to rule create, detail, and edit flows (elastic#60108) [Fleet] Add config revision to fleet agents (elastic#60292) Allow kbn-config-schema to ignore unknown keys (elastic#59560) [ML] Functional tests - disable df analytics clone tests skip flaky suite (elastic#58643) (elastic#58991) [FTR] Add support for --include and --exclude files via tags (elastic#60123) [SIEM] Fix link on overview page (elastic#60348) skip flaky test (elastic#60369) [Endpoint] Adds take action dropdown and tests to alert details flyout (elastic#59242) [Lens] Simplify state management from visualization (elastic#58279) Changing default type to start and allowing it to be configured by the event category (elastic#60323) [ML] Adds the class_assignment_objective to classification (elastic#60358) [TSVB] fix text color when using custom background color (elastic#60261) Fix import to timefilter from in TSVB (elastic#60296) [NP] Get rid of usage redirectWhenMissing service (elastic#59777) ...
* alerting/view-in-app: (53 commits) fixed typo handle optional alerting plugin do not update cell background if is label cell (elastic#60308) FTR configurable test users (elastic#52431) [Reporting] Wholesale moves client to newest-platform (elastic#58945) [Ingest] Support `show_user` package registry flag (elastic#60338) [SIEM] Adds 'Closes one signal when more than one opened signals are selected' test again (elastic#60380) [SIEM][Detections Engine] - Add rule markdown field to rule create, detail, and edit flows (elastic#60108) [Fleet] Add config revision to fleet agents (elastic#60292) Allow kbn-config-schema to ignore unknown keys (elastic#59560) [ML] Functional tests - disable df analytics clone tests skip flaky suite (elastic#58643) (elastic#58991) [FTR] Add support for --include and --exclude files via tags (elastic#60123) [SIEM] Fix link on overview page (elastic#60348) skip flaky test (elastic#60369) [Endpoint] Adds take action dropdown and tests to alert details flyout (elastic#59242) [Lens] Simplify state management from visualization (elastic#58279) Changing default type to start and allowing it to be configured by the event category (elastic#60323) [ML] Adds the class_assignment_objective to classification (elastic#60358) [TSVB] fix text color when using custom background color (elastic#60261) ...
Summary
This PR fix the foreground color of the TSVB timeseries chart when the user specify custom
background
color from the UI.In particular we are applying the following steps:
LIGHT_THEME
orDARK_THEME
themesno data
text colorsfix #60011
Checklist
Delete any items that are not applicable to this PR.