-
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
Update tooltip content and styling on update() #6181
Conversation
Found a mistake still that did not set lastActive to an empty initially. This resulted in #3791 breaking again, so needed to fix it. |
I believe there was an objection to calling |
I don't think its possible. |
@kurkle can you clarify why you don't think it's possible? |
To clarify, it certainly is possible, it just does not work correctly 😏 And the reason is: |
I guess this PR basically does what was proposed here: |
src/core/core.controller.js
Outdated
|
||
if (me._lastEvent && me.animating) { | ||
// If, during animation, element under mouse changes, let's react to that. | ||
me.active = me.getElementsAtEventForMode(me._lastEvent, hoverOptions.mode, hoverOptions); |
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.
Why not simply calling eventHandler
but duplicating code in handleEvent
? I think other logic such as calling the onHover
callback is also needed.
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.
That is probably right, I replaced these lines now with a call to eventHandler.
src/core/core.controller.js
Outdated
} else { | ||
me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions); | ||
me._lastEvent = e; |
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.
If 'click'
event is picked here, this issue will occur.
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.
I cannot reproduce that issue in the codepen I have provided with the PR code, I think that issue there was with refiring the actual click event.
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.
I see this issue when clicking the legend in your codepen.
src/core/core.tooltip.js
Outdated
} else { | ||
me._active = me._chart.getElementsAtEventForMode(e, options.mode, options); | ||
me._lastEvent = e; |
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.
Same as above.
Updated codepen: PR 6181 Updated |
I'd love to see this merged. Require it for project with a constantly updating dataset. Thanks for all your hard work @Evertvdw |
@benmccann @nagix can you review this? |
Implemented the rieview, so everything is good now? |
Can you update the pen too? |
Yes, updated the PR pen: https://codepen.io/Evertvdw/pen/PgqbWq |
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.
LGTM
Hi, I' also waiting for this update. :-) |
Rebased and merged in #6635 |
@benmccann Sorry, I forgot about it again, but thanks for doing it! |
Fixes issue #4991
Another attempt at this issue, credits go to @kurkle.
The tooltip is now updated based on the new data that is visible under the mouse and hides if that point is no longer visible.
To do this the last mouse event is stored and passed to the eventhandler upon update. The data for the tooltip is updated during transition as well as the hover styling of the point.
For a working example of this PR: https://codepen.io/Evertvdw/pen/PgqbWq
Current behaviour: https://codepen.io/Evertvdw/pen/QPbdLQ