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

feat(cursor): improve theme styling for crosshair #980

Merged
merged 7 commits into from
Jan 19, 2021

Conversation

markov00
Copy link
Member

Summary

This PR improved the styling for the crosshair cursor:

  • the crosshair theme has a more specific crossLine styling object that is used style the horizontal line when using a TooltipType.Crosshairs
interface CrosshairStyle {
  band: FillStyle & Visible;
  line: StrokeStyle & Visible & Partial<StrokeDashArray>;
  crossLine: StrokeStyle & Visible & Partial<StrokeDashArray>;
}
  • the "vertical" now correctly pick the style from the theme depending on its shape (using the band style when the chart has at least one bar series, using the line style when the chart is composed of line or/and areas) and using the crossLine to style the horizontal crossing line

Screenshot 2021-01-15 at 10 29 08

  • The cursor implementation was also refactored using SVG instead of DIV elements allowing us to correctly align the cursors to the underlying scale, fixing the current misalignment visible in various cases

Before and after
Screenshot 2021-01-15 at 10 21 52Screenshot 2021-01-15 at 10 21 45

fix #925

@markov00 markov00 added enhancement New feature or request :interactions Interactions related issue labels Jan 15, 2021
@markov00
Copy link
Member Author

Hey @miukimiu could you please take a look at the default color I've used here for the line cursor?
I think we should update the EUI theme to use the right color for the crosshair.line to have a smooth transition when updating both libraries in kibana
You can test the default color assigned here in the local storybook at http://localhost:9001/?path=/story/stylings--dark-theme and playing with dark mode or light mode and with or without bars

@codecov-io
Copy link

codecov-io commented Jan 15, 2021

Codecov Report

Merging #980 (17b85bf) into master (89d4bdb) will decrease coverage by 0.20%.
The diff coverage is 58.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #980      +/-   ##
==========================================
- Coverage   71.08%   70.87%   -0.21%     
==========================================
  Files         344      344              
  Lines       10959    10971      +12     
  Branches     2303     2309       +6     
==========================================
- Hits         7790     7776      -14     
- Misses       3155     3181      +26     
  Partials       14       14              
Flag Coverage Δ
unittests 70.87% <58.53%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/utils/themes/dark_theme.ts 100.00% <ø> (ø)
src/utils/themes/light_theme.ts 100.00% <ø> (ø)
src/utils/themes/theme.ts 100.00% <ø> (ø)
...rc/chart_types/xy_chart/renderer/dom/crosshair.tsx 70.17% <50.00%> (-10.19%) ⬇️
.../chart_types/xy_chart/crosshair/crosshair_utils.ts 73.49% <61.53%> (-19.66%) ⬇️
..._types/xy_chart/state/selectors/get_cursor_band.ts 93.02% <100.00%> (+0.16%) ⬆️
..._types/xy_chart/state/selectors/get_cursor_line.ts 100.00% <100.00%> (ø)
...s/xy_chart/state/selectors/get_tooltip_position.ts 75.00% <0.00%> (-18.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89d4bdb...7dd42b2. Read the comment docs.

Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested locally. This looks so much nicer and cleaner using the svg instead 👍

Copy link
Contributor

@rshen91 rshen91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@elizabetdev elizabetdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

I tested locally and just added a few suggestions. I can update the EUI theme once the PR is merged.

strokeWidth: 1,
visible: true,
},
crossLine: {
stroke: '#777',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line.stroke and crossLine.stroke could use the same color. I think the #98A2B3 has more contrast.

Suggested change
stroke: '#777',
stroke: '#98A2B3',

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note: these styles are only default to elastic charts. If you want this change reflected in kibana you'd need to update the eui charts theme.

https://github.com/elastic/eui/blob/d16d296ae4d06a6337a4a2534f4d3bfacff932ea/src/themes/charts/themes.ts#L172-L181

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in #5e8f506

@@ -176,6 +176,11 @@ export const DARK_THEME: Theme = {
visible: true,
},
line: {
stroke: '#535966',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line.stroke and crossLine.stroke could use the same color. And #999 has more contract on darker backgrounds:

Suggested change
stroke: '#535966',
stroke: '#999',

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in #5e8f506

@markov00 markov00 merged commit 6c4dafd into elastic:master Jan 19, 2021
@markov00 markov00 deleted the 2021_01_14-fix_crosshair branch January 19, 2021 13:06
github-actions bot pushed a commit that referenced this pull request Jan 30, 2021
# [24.5.0](v24.4.0...v24.5.0) (2021-01-30)

### Bug Fixes

* add theme min radius to point shape ([#996](#996)) ([eb37175](eb37175))
* align tooltip z-index to EUI tooltip z-index ([#931](#931)) ([ffd626b](ffd626b))
* chart state and series functions cleanup ([#989](#989)) ([944ac6c](944ac6c))
* create unique ids for dot icons ([#971](#971)) ([e1ce768](e1ce768))
* external tooltip legend extra value sync ([#993](#993)) ([13ad05a](13ad05a))
* **legend:** disable focus and keyboard navigation for legend in partition ch… ([#952](#952)) ([03bd2f7](03bd2f7))
* **legend:** hierarchical legend order should follow the tree paths ([#947](#947)) ([f9218ad](f9218ad)), closes [#944](#944)
* **legend:** remove ids for circles ([#973](#973)) ([b3f4f90](b3f4f90))

### Features

* **cursor:** improve theme styling for crosshair ([#980](#980)) ([6c4dafd](6c4dafd))
* **legend:**  display pie chart legend extra ([#939](#939)) ([d14de01](d14de01))
* **legend:** add keyboard navigation ([#880](#880)) ([87c227d](87c227d))
* **partition:** Flame and icicle chart ([#965](#965)) ([3df73d0](3df73d0))
* **partition:** legend hover options ([#978](#978)) ([f810d94](f810d94))
* **xy:** support multiple point shapes on line, area and bubble charts ([#988](#988)) ([1392b7d](1392b7d))
@markov00
Copy link
Member Author

🎉 This PR is included in version 24.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Jan 30, 2021
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [24.5.0](elastic/elastic-charts@v24.4.0...v24.5.0) (2021-01-30)

### Bug Fixes

* add theme min radius to point shape ([opensearch-project#996](elastic/elastic-charts#996)) ([98089a9](elastic/elastic-charts@98089a9))
* align tooltip z-index to EUI tooltip z-index ([opensearch-project#931](elastic/elastic-charts#931)) ([f7f1f6f](elastic/elastic-charts@f7f1f6f))
* chart state and series functions cleanup ([opensearch-project#989](elastic/elastic-charts#989)) ([42a7af0](elastic/elastic-charts@42a7af0))
* create unique ids for dot icons ([opensearch-project#971](elastic/elastic-charts#971)) ([0b3e00f](elastic/elastic-charts@0b3e00f))
* external tooltip legend extra value sync ([opensearch-project#993](elastic/elastic-charts#993)) ([7e1096e](elastic/elastic-charts@7e1096e))
* **legend:** disable focus and keyboard navigation for legend in partition ch… ([opensearch-project#952](elastic/elastic-charts#952)) ([dfff3e2](elastic/elastic-charts@dfff3e2))
* **legend:** hierarchical legend order should follow the tree paths ([opensearch-project#947](elastic/elastic-charts#947)) ([7b70186](elastic/elastic-charts@7b70186)), closes [opensearch-project#944](elastic/elastic-charts#944)
* **legend:** remove ids for circles ([opensearch-project#973](elastic/elastic-charts#973)) ([ed98481](elastic/elastic-charts@ed98481))

### Features

* **cursor:** improve theme styling for crosshair ([opensearch-project#980](elastic/elastic-charts#980)) ([0248ad6](elastic/elastic-charts@0248ad6))
* **legend:**  display pie chart legend extra ([opensearch-project#939](elastic/elastic-charts#939)) ([672a4df](elastic/elastic-charts@672a4df))
* **legend:** add keyboard navigation ([opensearch-project#880](elastic/elastic-charts#880)) ([b471a94](elastic/elastic-charts@b471a94))
* **partition:** Flame and icicle chart ([opensearch-project#965](elastic/elastic-charts#965)) ([9e8b1f7](elastic/elastic-charts@9e8b1f7))
* **partition:** legend hover options ([opensearch-project#978](elastic/elastic-charts#978)) ([acd1339](elastic/elastic-charts@acd1339))
* **xy:** support multiple point shapes on line, area and bubble charts ([opensearch-project#988](elastic/elastic-charts#988)) ([4f23b4f](elastic/elastic-charts@4f23b4f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request :interactions Interactions related issue released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crosshair line for Line / Area charts is too light
5 participants