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

Adjust vertical alignment of tooltip items #6292

Merged
merged 1 commit into from Jun 19, 2019
Merged

Conversation

nagix
Copy link
Contributor

@nagix nagix commented May 23, 2019

Currently, texts in a tooltip are aligned to 'top', but some browsers (in particular, Safari on Mac and IE/Edge on Win) add extra space above the texts, and they are shifted down a few pixels as reported in #3393. As the alignment of legend items were fixed in #4318, this PR makes similar changes to tooltip items by using textBaseline = 'middle'.

As shown below, the changes only affect the results in Safari (Mac), IE (Win) and Edge (Win).

Master: https://jsfiddle.net/nagix/v8qhgczu/

Browser Image
Safari (Mac) Screen Shot 2019-05-23 at 1 34 26 PM
FireFox (Mac) Screen Shot 2019-05-23 at 1 44 34 PM
Chrome (Mac) Screen Shot 2019-05-23 at 1 45 21 PM
IE (Win) Screen Shot 2019-05-23 at 2 01 45 PM
Edge (Win) Screen Shot 2019-05-23 at 2 02 56 PM
FireFox (Win) Screen Shot 2019-05-23 at 2 03 38 PM
Chrome (Win) Screen Shot 2019-05-23 at 2 04 10 PM

This PR: https://jsfiddle.net/nagix/k9gzv5wf/

Browser Image
Safari (Mac) Screen Shot 2019-05-23 at 1 34 44 PM
FireFox (Mac) Screen Shot 2019-05-23 at 1 56 35 PM
Chrome (Mac) Screen Shot 2019-05-23 at 1 59 16 PM
IE (Win) Screen Shot 2019-05-23 at 2 05 36 PM
Edge (Win) Screen Shot 2019-05-23 at 2 06 24 PM
FireFox (Win) Screen Shot 2019-05-23 at 2 07 04 PM
Chrome (Win) Screen Shot 2019-05-23 at 2 07 36 PM

Fixes #3393

@nagix nagix mentioned this pull request May 23, 2019
@benmccann benmccann changed the title Adjust virtical alignment of tooptip items Adjust vertical alignment of tooltip items May 23, 2019
Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

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

Looks good, just wondering if aligning text would make any sense for displays with device pixel ratio > 1.

src/core/core.tooltip.js Show resolved Hide resolved
@etimberg etimberg requested a review from simonbrunel June 9, 2019 21:08
@etimberg etimberg merged commit d81914e into chartjs:master Jun 19, 2019
@nagix nagix added this to the Version 2.9 milestone Jun 19, 2019
@nagix nagix deleted the issue-6292 branch June 19, 2019 14:40
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Font baseline shift
4 participants