-
Notifications
You must be signed in to change notification settings - Fork 893
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
fix(timeline): Fix yaxis label color in dark mode #3698
fix(timeline): Fix yaxis label color in dark mode #3698
Conversation
- Render label as HTML instead of in the Canvas so that it picks up text color from CSS theme - Update CSS styles of yaxis label to match chart title - Update HTML rendering to support custom color overrides via inline styles Signed-off-by: Josh Romero <rmerqg@amazon.com>
Fixes opensearch-project#2250 Signed-off-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: Josh Romero <rmerqg@amazon.com>
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #3698 +/- ##
==========================================
- Coverage 66.44% 66.44% -0.01%
==========================================
Files 3209 3209
Lines 61633 61633
Branches 9507 9506 -1
==========================================
- Hits 40955 40954 -1
- Misses 18398 18400 +2
+ Partials 2280 2279 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
The change might be small, but i can tell that you did your homework on this one. Also thanks for the helpful PR description. made this review a lot easier :)
+1 |
- Render label as HTML instead of in the Canvas so that it picks up text color from CSS theme - Update CSS styles of yaxis label to match chart title - Update HTML rendering to support custom color overrides via inline styles Fixes #2250 Signed-off-by: Josh Romero <rmerqg@amazon.com> (cherry picked from commit 868c822) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
- Render label as HTML instead of in the Canvas so that it picks up text color from CSS theme - Update CSS styles of yaxis label to match chart title - Update HTML rendering to support custom color overrides via inline styles Fixes #2250 Signed-off-by: Josh Romero <rmerqg@amazon.com> (cherry picked from commit 868c822) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…#3698) - Render label as HTML instead of in the Canvas so that it picks up text color from CSS theme - Update CSS styles of yaxis label to match chart title - Update HTML rendering to support custom color overrides via inline styles Fixes opensearch-project#2250 Signed-off-by: Josh Romero <rmerqg@amazon.com> Signed-off-by: vagimeli <vagimeli@amazon.com>
…#3698) - Render label as HTML instead of in the Canvas so that it picks up text color from CSS theme - Update CSS styles of yaxis label to match chart title - Update HTML rendering to support custom color overrides via inline styles Fixes opensearch-project#2250 Signed-off-by: Josh Romero <rmerqg@amazon.com> Signed-off-by: David Sinclair <david@sinclair.tech>
Description
Before:
Screen.Recording.2023-03-27.at.6.39.23.PM.mov
After:
Screen.Recording.2023-03-29.at.4.27.19.PM.mov
Explanation
There are a couple things going on here. The timeline vis was previously always setting the property
axisLabelUseCanvas
totrue
for the yAxis. Withinflot.js
, which is the legacy charting library used by timeline, that property causes the yAxis label to be rendered as part of the<canvas>
element, which means it doesn't pick up any of the default CSS styles. In contrast, other chart text (such as the chart title) are rendered via HTML, which means they get the appropriate EUI text color applied, regardless of whether the dark or light theme is selected.As far as I know, we don't currently have any good mechanisms to access theme colors within JS/TS files. If we did, it would be simple to just update the default color to just pull from the current theme text color:
OpenSearch-Dashboards/packages/osd-ui-shared-deps/flot_charts/jquery_flot_axislabels.js
Line 94 in 7322f7f
Instead, the fix was to switch the rendering of the yAxis label to HTML, which flot already supports. Unfortunately, the HTML renderers (
HtmlAxisLabel
andCssTransformAxisLabel
) were missing support for custom colors, which timeline visualizations support as part of theyaxis
expression. So I added custom color support to those renderers to be backwards compatible with timeline expressions that had set a custom color for that label. Finally, I styled the axis label to match the chart title.Issues Resolved
Fixes #2250
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr