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(annotation): position custom rect_annotation tooltip by elastic-charts styles #247

Merged

Conversation

emmacunningham
Copy link
Contributor

@emmacunningham emmacunningham commented Jun 19, 2019

BREAKING CHANGE: this changes the type signature of RectAnnotation.renderTooltip? from (position, details) => JSX.Element to (details) => JSX.Element. This allows the user to pass in a custom element without having to do the heavy lifting of writing the container positioning styles themselves.

Summary

Previously, the renderTooltip? property of a RectAnnotationSpec was used in such a way that if defined, the returned component would be used instead of the default tooltip component to render the tooltip details. However, it was implemented in a way that required the user to also use the position information and write their own styles to position the tooltip correctly. This lends to a not great developer user experience when the user just wants to pass a custom component (as in the Storybook case where we just need to include an icon) because then the developer needs to write their own CSS styles to handle the position of the tooltip container itself.

Instead, now we embed the custom component within the tooltip container so that the user does not need to worry about positioning. This also helps with making it so that the user still has customization capabilities while remaining some consistence with respect to the rest of the elastic-chart internal style.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)

  • This was checked for cross-browser compatibility, including a check against IE11
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios
  • Each commit follows the convention

BREAKING CHANGE: this changes the type signature of `RectAnnotation.renderTooltip?` from `(position, details) => JSX.Element` to `(details) => JSX.Element`.  This allows the user to pass in a custom element without having to do the heavy lifting of writing the container positioning styles themselves.
@emmacunningham emmacunningham changed the title feat(annotation): simplify custom tooltip function feat(annotation): position custom rect_annotation tooltip by elastic-charts styles Jun 19, 2019
@codecov-io
Copy link

codecov-io commented Jun 19, 2019

Codecov Report

Merging #247 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #247   +/-   ##
=======================================
  Coverage   97.76%   97.76%           
=======================================
  Files          36       36           
  Lines        2641     2641           
  Branches      593      593           
=======================================
  Hits         2582     2582           
  Misses         52       52           
  Partials        7        7
Impacted Files Coverage Δ
src/lib/series/specs.ts 100% <ø> (ø) ⬆️
src/state/annotation_utils.ts 100% <ø> (ø) ⬆️

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 80a8f8e...76410ad. 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.

Tested locally, LGTM! 🎉

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Code LGTM

@emmacunningham emmacunningham merged commit 982bc63 into elastic:master Jun 24, 2019
markov00 pushed a commit that referenced this pull request Jun 24, 2019
# [7.0.0](v6.3.0...v7.0.0) (2019-06-24)

### Features

* **annotation:** simplify custom tooltip function ([#247](#247)) ([982bc63](982bc63))

### BREAKING CHANGES

* **annotation:** this changes the type signature of `RectAnnotation.renderTooltip?` from `(position, details) => JSX.Element` to `(details) => JSX.Element`.  This allows the user to pass in a custom element without having to do the heavy lifting of writing the container positioning styles themselves.
@markov00
Copy link
Member

🎉 This PR is included in version 7.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Jun 24, 2019
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [7.0.0](elastic/elastic-charts@v6.3.0...v7.0.0) (2019-06-24)

### Features

* **annotation:** simplify custom tooltip function ([opensearch-project#247](elastic/elastic-charts#247)) ([b191628](elastic/elastic-charts@b191628))

### BREAKING CHANGES

* **annotation:** this changes the type signature of `RectAnnotation.renderTooltip?` from `(position, details) => JSX.Element` to `(details) => JSX.Element`.  This allows the user to pass in a custom element without having to do the heavy lifting of writing the container positioning styles themselves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants