Skip to content

How to force tooltip to hide? #9982

Answered by beibean
beibean asked this question in Q&A
Dec 13, 2021 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

Thank you both for suggestions. I finally followed a solution similar to what @kurkle said but with a slightly difference, instead of setting active elements to none, I simulate a fake pointerdown event over chartArea when needed. Doing this, I guess chart.js internally sets active elements to none both for hover and tooltip.

Here is the code i used in case it's useful for someone else:

this.elRef.nativeElement.shadowRoot.getElementById('chart').dispatchEvent(new PointerEvent('pointerdown'));

FYI:

I just tested @kurkle solution as follows, and it's not working.

    this.chart.setActiveElements([]);
    this.chart.tooltip.setActiveElements([], { x: 0, y: 0 });

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@kurkle
Comment options

@beibean
Comment options

@kurkle
Comment options

@beibean
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by beibean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants