-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Avoid tooltip truncation in x axis if there is enough space #3998
Avoid tooltip truncation in x axis if there is enough space #3998
Conversation
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.
@kaidohallik could you add a test case that shows how this changes the rendering?
@etimberg I started coding tests. In this process I think I found additional improvement to #1731 - if calculated tooltip.xAlign='center' and tooltip text is long then this is truncated though there is space to show this tooltip.
|
Let's do more commits here |
8664072
to
996927c
Compare
Work finished with this PR. |
src/core/core.tooltip.js
Outdated
} else { | ||
model.opacity = 0; | ||
} | ||
|
||
model.xAlign = alignment.xAlign; | ||
model.yAlign = alignment.yAlign; | ||
model.x = backgroundPoint.x; | ||
model.xCaret = backgroundPoint.xCaret; |
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.
Would it make sense / be useful to also have a way to override the yCaret
position as well?
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.
After reading this comment I started thinking that why not to use caretX, maybe can avoid this xCaret complexity in code.
And seems that this current code can be replaced with x2 = vm.caretX;
.
So I made new commit where I removed xCaret and made change described above.
In y axis direction tooltips seem to be working ok and no need for changes.
It's quite a lot commits here already. Should I rebase?
hopefully this could be included in 2.7 milestone, thanks |
@simonbrunel looks like we both approved this. Do you think we should merge it for 2.7? |
@kaidohallik could you rebase this PR so that it can be merged? |
Truncation up to caretSize pixels could happen if label text produced tooltip element with size width: * left side tooltip: width < x and width > x - caretSize * right side tooltip: width < chartWidth - x and width > chartWidth - x - caretSize Default caretSize = 5, so with default configuration truncation up to 5 pixels could happen.
use whole chart area for displaying tooltip
d8697ed
to
dd668a3
Compare
@benmccann rebase done |
Looks like the build is failing with some linter errors. @kaidohallik can you fix and then I'll merge this |
@etimberg lint errors fixed |
…3998) * In tooltip x align calculation take into account caretSize Truncation up to caretSize pixels could happen if label text produced tooltip element with size width: * left side tooltip: width < x and width > x - caretSize * right side tooltip: width < chartWidth - x and width > chartWidth - x - caretSize Default caretSize = 5, so with default configuration truncation up to 5 pixels could happen. * avoid tooltip truncation if possible use whole chart area for displaying tooltip * in xAlign calculation take into account caretPadding * add tests for tooltip truncation avoid logic * use caretX instead of xCaret * fix lint errors
…3998) * In tooltip x align calculation take into account caretSize Truncation up to caretSize pixels could happen if label text produced tooltip element with size width: * left side tooltip: width < x and width > x - caretSize * right side tooltip: width < chartWidth - x and width > chartWidth - x - caretSize Default caretSize = 5, so with default configuration truncation up to 5 pixels could happen. * avoid tooltip truncation if possible use whole chart area for displaying tooltip * in xAlign calculation take into account caretPadding * add tests for tooltip truncation avoid logic * use caretX instead of xCaret * fix lint errors
Truncation up to caretSize pixels could happen if label text produced tooltip element with size width:
width < x
andwidth > x - caretSize
width < chartWidth - x
andwidth > chartWidth - x - caretSize
Default caretSize = 5, so with default configuration truncation up to 5 pixels could happen.
Current problematic behaviour can be viewed in http://codepen.io/kaidohallik/pen/gmLQbN
'Blue exactly bad labelllll' is truncated.
After changing
caretSize: 10
tocaretSize: 0
no truncation, all is shown correctly.It can fix someones problems in #1731
It's improvement of #1840